Mercurial > hg > Feedworm
comparison Mapping.py @ 34:5813e3c10f14
move the database logic out into its own module. Make everything reload safe so that multiple sessions can be created from interactive sessions
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Wed, 05 May 2010 02:14:05 +0200 |
parents | ee1432a91141 |
children | aaec263f07ca |
comparison
equal
deleted
inserted
replaced
33:f371d02fa09d | 34:5813e3c10f14 |
---|---|
10 from sqlalchemy import Table | 10 from sqlalchemy import Table |
11 from sqlalchemy import Text | 11 from sqlalchemy import Text |
12 from sqlalchemy.orm import mapper | 12 from sqlalchemy.orm import mapper |
13 from sqlalchemy.orm import relation | 13 from sqlalchemy.orm import relation |
14 | 14 |
15 mappingDefined = False | |
16 | |
15 def createMapping(engine): | 17 def createMapping(engine): |
18 """ Make sure the mapping is defined only once. This is not really needed for the feed updater | |
19 or the GUI app but comes in handy when working interactively with the system. """ | |
20 global mappingDefined | |
21 if not mappingDefined: | |
22 _createMapping(engine) | |
23 mappingDefined = True | |
24 | |
25 def _createMapping(engine): | |
16 metadata = MetaData(engine) | 26 metadata = MetaData(engine) |
17 | 27 |
18 feedTable = Table("feed", metadata, | 28 feedTable = Table("feed", metadata, |
19 Column("pk", Integer, primary_key=True), | 29 Column("pk", Integer, primary_key=True), |
20 Column("title", String(255), nullable=False), | 30 Column("title", String(255), nullable=False), |