Mercurial > hg > Feedworm
comparison Database.py @ 57:254d5b89a6ca
make sqlalchemy logging configurable through the --databaseLogging commandline parameter
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Fri, 23 Jul 2010 04:39:08 +0200 |
parents | 22214d79ed41 |
children | 842727971796 |
comparison
equal
deleted
inserted
replaced
56:c82f5538733c | 57:254d5b89a6ca |
---|---|
1 | 1 |
2 import Mapping | 2 import Mapping |
3 import sqlalchemy | 3 import sqlalchemy |
4 import sqlalchemy.orm | 4 import sqlalchemy.orm |
5 import sys | 5 import sys |
6 import util | |
6 | 7 |
7 # Keep the connection to the database only once. The feed updater and the GUI app will | 8 # Keep the connection to the database only once. The feed updater and the GUI app will |
8 # operate on a single engine/session but this comes in handy for interactive use | 9 # operate on a single engine/session but this comes in handy for interactive use |
9 engine = None | 10 engine = None |
10 SessionMaker = None | 11 SessionMaker = None |
23 return sys.argv[1] | 24 return sys.argv[1] |
24 | 25 |
25 def initEngine(databaseUrl): | 26 def initEngine(databaseUrl): |
26 global engine | 27 global engine |
27 if engine is None: | 28 if engine is None: |
28 engine = sqlalchemy.create_engine(databaseUrl, echo=True) | 29 verbose = util.databaseLoggingEnabled() |
30 engine = sqlalchemy.create_engine(databaseUrl, echo=verbose) | |
29 | 31 |
30 def initSessionMaker(): | 32 def initSessionMaker(): |
31 global SessionMaker | 33 global SessionMaker |
32 if SessionMaker is None: | 34 if SessionMaker is None: |
33 SessionMaker = sqlalchemy.orm.sessionmaker(bind=engine) | 35 SessionMaker = sqlalchemy.orm.sessionmaker(bind=engine) |