From ae6cbac58db45e4438a1062e8ee42bfb7ad51f0a Mon Sep 17 00:00:00 2001 From: Holger Frey Date: Thu, 28 Sep 2017 11:35:46 +0200 Subject: [PATCH] initializing database will delete existing sqlite file --- ordr2/scripts/initializedb.py | 6 ++++++ 1 file changed, 6 insertions(+) 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)