mardi 7 avril 2015

How to return value web from sqlite?

This is my code. I would like to show the values on the web. How would do it?



import sqlite3

def application(environ, start_response):

db = sqlite3.connect('/root/example.db')
db.row_factory = sqlite3.Row
cursor = db.cursor()
cursor.execute('''SELECT id, message,date FROM table''')
for row in cursor:
print('{0} : {1}, {2}'.format(row['id'], row['message'], row['date']))
db.close()

start_response('200 OK', [('Content-Type', 'text/html; charset=utf-8')])

Aucun commentaire:

Enregistrer un commentaire