diff --git a/ordr2/scripts/initializedb.py b/ordr2/scripts/initializedb.py index 5a7c676..8ba54d2 100644 --- a/ordr2/scripts/initializedb.py +++ b/ordr2/scripts/initializedb.py @@ -1,6 +1,7 @@ import os import sys import transaction +from urllib.parse import urlparse from pyramid.paster import ( get_appsettings, @@ -33,6 +34,11 @@ def main(argv=sys.argv): setup_logging(config_uri) settings = get_appsettings(config_uri, options=options) + # remove an existing sqlite database to issue a restart + database_url = urlparse(settings['sqlalchemy.url']) + if database_url.scheme == 'sqlite' and os.path.isfile(database_url.path): + os.remove(path) + engine = get_engine(settings) Base.metadata.create_all(engine)