#!/usr/bin/python |
import MySQLdb |
print "Content-Type: text/html" |
print |
print "<html><head><title>Books</title></head>" |
print "<body>" |
print "<h1>Books</h1>" |
print "<ul>" |
connection = MySQLdb.connect(user = 'me' , passwd = 'letmein' , db = 'my_db' ) |
cursor = connection.cursor() |
cursor.execute( "SELECT name FROM books ORDER BY pub_date DESC LIMIT 10" ) |
for row in cursor.fetchall(): |
print "<li>%s</li>" % row[ 0 ] |
print "</ul>" |
print "</body></html>" |
connection.close() |