import os
import sqlite3
import csv

def data (db):
  for title, date_added in db.execute ("SELECT title, date_added FROM whatsnew ORDER BY title"):
    yield title.encode ("utf8"), date_added

db = sqlite3.connect ("books.db")
writer = csv.writer (open ("books.csv", "wb"))
writer.writerow (["Title", "Date Added"])
writer.writerows (data (db))

os.startfile ("books.csv")
11