Mercurial > hg > Feedworm
diff Database.py @ 37:22214d79ed41
database URL must be given as commandline argument now, no need for creating complicated config files. Add a menu entry for opening the selected article in browser.
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Fri, 14 May 2010 06:16:05 +0200 |
parents | 5813e3c10f14 |
children | 254d5b89a6ca |
line wrap: on
line diff
--- a/Database.py Wed May 05 03:10:15 2010 +0200 +++ b/Database.py Fri May 14 06:16:05 2010 +0200 @@ -2,7 +2,7 @@ import Mapping import sqlalchemy import sqlalchemy.orm -import util +import sys # Keep the connection to the database only once. The feed updater and the GUI app will # operate on a single engine/session but this comes in handy for interactive use @@ -10,16 +10,22 @@ SessionMaker = None def createSession(): - databaseUrl = util.loadDatabaseUrl() + databaseUrl = _getDatabaseUrl() initEngine(databaseUrl) Mapping.createMapping(engine) initSessionMaker() return SessionMaker() +def _getDatabaseUrl(): + if len(sys.argv) < 2: + print("Usage: %s <database url>" % (sys.argv[0])) + sys.exit(1) + return sys.argv[1] + def initEngine(databaseUrl): global engine if engine is None: - engine = sqlalchemy.create_engine(databaseUrl, echo=False) + engine = sqlalchemy.create_engine(databaseUrl, echo=True) def initSessionMaker(): global SessionMaker