comparison feedupdate-main.py @ 2:8a624ee48a74

First skeleton for sqlalchemy: define the mapping and create the first feed
author Dirk Olmes <dirk@xanthippe.ping.de>
date Mon, 26 Apr 2010 17:40:55 +0200
parents
children e0199f383442
comparison
equal deleted inserted replaced
1:8b0280b4bb09 2:8a624ee48a74
1 #!/usr/bin/env python
2
3 from ConfigParser import ConfigParser
4 from Feed import Feed
5 import Mapping
6 import socket
7 from sqlalchemy import create_engine
8 from sqlalchemy.orm import sessionmaker
9
10 def loadDatabaseProperties():
11 hostname = socket.gethostname()
12 filename = "database-%s.ini" % hostname
13
14 parser = ConfigParser();
15 parser.read(filename)
16 return parser.get("database", "url")
17
18 def createFeed(session):
19 newFeed = Feed("Joel on Software", "http://www.joelonsoftware.com/rss.xml")
20 session.add(newFeed)
21 session.commit()
22
23 if __name__ == "__main__":
24 databaseUrl = loadDatabaseProperties()
25 engine = create_engine(databaseUrl,echo=True)
26 Mapping.createMapping(engine)
27 SessionMaker = sessionmaker(bind = engine)
28 session = SessionMaker()
29
30 createFeed(session)