Try this, using prepared statements:

# set up database cursor...
sql   = "INSERT foo (id, text) VALUES (%d, %s)"
elem  = ElementTree.fromstring(xmlstr)
nodes = elem.findall('xmlnode')
for row in nodes:
    valueList = (row.get('id'), row.get('text'))
    cursor.execute(sql, valueList)


As indicated, I don't think storing the escaped value in the database will do you any good. Use the actual values in the DB, it will make your life very much easier down the road.

Reading xml node attributes in their escaped forms in python
I am combining two lists of separate objects into a single combined list. The below code works perfectly but it is not the most elegant or efficient solution. Is there a better solution?

var articles = context.Articles.Where(a =&gt; a.Author.ID == authorID).ToList();
var reviews = context.Reviews.Where(a =&gt; a.Author.ID == authorID).ToList();

var items = articles.ConvertAll(x =&gt; new ItemViewModel(x.ID, x.Title, x.Summary, "article", x.PublishDate)).Union(reviews.ConvertAll(r =&gt; new ItemViewModel(r.ID, r.Title, r.Summary, "review", r.PublishDate))).Take(20).OrderByDescending(i =&gt; i.publishDate);

