##^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^Lance Simms, Stanford University 2009
##This script is an example of how I can use MySQL with python
##It simply outputs the version number to the screen

##IMPORT THE MODULE LOCATED IN /u1/ki
import MySQLdb
import sys

##Open up the connection and include some error handling
try:
	conn=MySQLdb.connect (host="localhost",
	           	      user="root",
		              passwd="mysql",
	        	      db="test")
except MySQLdb.Error, e:
	print "All Bad Error"
	print "Error $d: $s" % (e.args[0],e.args[1])
	sys.exit

##invoke the cursor() method to create a cursor object for processing 
##queries

cursor=conn.cursor()

try:
	cursor.execute("CREATE DATABASE my_test")
	print "Database Created"
except MySQLdb.Error, e:
        print "Error"

try:
	cursor.execute("use my_test");
	cursor.execute('CREATE TABLE 5_10_2005(Filename varchar(20),'+
					       'NPIX mediumint,'+
					       'MEAN float,'+
					       'STDEV float,'+
				               'MIN float,'+
					       'Max float);')
except MySQLdb.Error, e:
        print e

cursor.close()
