diff backend/sqlalchemy/Database.py @ 137:5b131f82057d

allow choosing the backend via commandline option
author Dirk Olmes <dirk@xanthippe.ping.de>
date Tue, 23 Aug 2011 14:36:58 +0200
parents 04a730f9d07d
children bb3c851b18b1
line wrap: on
line diff
--- a/backend/sqlalchemy/Database.py	Tue Aug 23 04:15:46 2011 +0200
+++ b/backend/sqlalchemy/Database.py	Tue Aug 23 14:36:58 2011 +0200
@@ -2,7 +2,7 @@
 from sqlalchemy.engine import create_engine
 from sqlalchemy.orm import sessionmaker
 import Mapping
-import sys
+import argparse
 import util
 
 # Keep the connection to the database only once. The feed updater and the GUI app will
@@ -19,10 +19,10 @@
     return SessionMaker()
 
 def _getDatabaseUrl():
-    if len(sys.argv) < 2:
-        print("Usage: %s <database url>" % (sys.argv[0]))
-        sys.exit(1)
-    return sys.argv[1]
+    parser = argparse.ArgumentParser()
+    parser.add_argument("--dburl", nargs="?", required=True, help="Database URL for the sqlalchemy backend")
+    args = parser.parse_known_args()
+    return args[0].dburl
 
 def initEngine(databaseUrl):
     global engine