Mercurial > hg > Feedworm
comparison database.py @ 12:9ede118b93ef
move session creation into its own module
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Wed, 28 Apr 2010 02:09:48 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
11:e87c54b3a216 | 12:9ede118b93ef |
---|---|
1 | |
2 from ConfigParser import ConfigParser | |
3 import Mapping | |
4 import socket | |
5 from sqlalchemy import create_engine | |
6 from sqlalchemy.orm import sessionmaker | |
7 | |
8 def createSession(): | |
9 databaseUrl = loadDatabaseUrl() | |
10 engine = create_engine(databaseUrl,echo=True) | |
11 Mapping.createMapping(engine) | |
12 SessionMaker = sessionmaker(bind = engine) | |
13 session = SessionMaker() | |
14 return session | |
15 | |
16 def loadDatabaseUrl(): | |
17 hostname = socket.gethostname() | |
18 filename = "database-%s.ini" % hostname | |
19 | |
20 parser = ConfigParser(); | |
21 parser.read(filename) | |
22 return parser.get("database", "url") |