Mercurial > hg > Feedworm
diff Mapping.py @ 4:e0199f383442
retrieve a feed for the given URL, store entries as feed_entry rows into the database
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Mon, 26 Apr 2010 19:33:07 +0200 |
parents | 8a624ee48a74 |
children | bfd47f55d85b |
line wrap: on
line diff
--- a/Mapping.py Mon Apr 26 17:43:48 2010 +0200 +++ b/Mapping.py Mon Apr 26 19:33:07 2010 +0200 @@ -1,11 +1,14 @@ from Feed import Feed +from FeedEntry import FeedEntry from sqlalchemy import Column +from sqlalchemy import ForeignKey from sqlalchemy import Integer from sqlalchemy import MetaData from sqlalchemy import String from sqlalchemy import Table from sqlalchemy.orm import mapper +from sqlalchemy.orm import relation def createMapping(engine): metadata = MetaData(engine) @@ -15,7 +18,21 @@ Column("name", String(255), nullable=False), Column("url", String(255), nullable=False) ) + + feedEntryTable = Table("feed_entry", metadata, + Column("pk", Integer, primary_key=True), + Column("id", String(255), nullable=False), + Column("url", String(255), nullable=False), + Column("title", String, nullable=False), + Column("summary", String, nullable=False), + Column("feed_id", Integer, ForeignKey("feed.pk")) + ) metadata.create_all() - mapper(Feed, feedTable) + mapper(FeedEntry, feedEntryTable) + mapper(Feed, feedTable, + properties = { + "entries" : relation(FeedEntry, backref = "feed") + } + )