#!/usr/bin/python # dbWebCreate.py # Name: John Magee # Username: mageejo # Date: 11/30/08 # A sample script to create a database table/file from the web server import cgi import cgitb; cgitb.enable() import time import sqlite3 as db import sys print "Content-Type: text/html" # HTML is following print # blank line, end of headers print "
" print "Attempting to create database file...
"
try:
conn = db.connect("address.db")
cursor = conn.cursor()
cursor.execute("""
CREATE TABLE address
(
firstname text,
lastname text,
email text,
note text
)
""")
conn.commit()
except:
print "Database file creation FAILED. Error information below:
"
print "
" print sys.exc_info() print "" else: print "Database file creation SUCCEEDED!!!
" print "Generated at ", time.ctime() print "
"