1
2
3
4
5 import datetime,PyRSS2Gen,sqlobject
6 from sqlobject.postgres import builder
7
8 con = builder()(user = 'user', passwd = '', host = 'localhost', db='name')
9
10
11 con.queryOne("SET client_encoding TO 'latin1'; SELECT 1;")
12
13 items = []
14 for res in con.queryAll("""SELECT title,url,datum,description FROM table ORDER BY datum DESC LIMIT 30"""):
15 items.append(
16 PyRSS2Gen.RSSItem(
17 title = res[0], link = res[1],
18 description = """<h2>%s</h2>on %s<br/><p>%s</p>"""%(res[0],res[2],res[]3),
19 guid = PyRSS2Gen.Guid(res[1]), pubDate = res[2]))
20
21
22 PyRSS2Gen.RSS2(
23 title = "sql2rss feed",
24 link = "http://localhost/die URL",
25 description = "The latest sql2rss news",
26 lastBuildDate = datetime.datetime.now(),
27 items = items).write_xml(open("sql2rss.xml", "w"))