#!/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 "Database Table Creation" print "

Database Table Creation

" print "This script attempts to create a database file and table!

" 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 "Check that the file is in the proper location." print "

" print "Generated at ", time.ctime() print "

"