import MySQLdb
conn=MySQLdb.Connect(host='localhost',user='root',passwd='')
cursor =conn.cursor()
cursor.execute('create database if not exists student')
#conn.commit()
conn.select_db('student')
cursor =conn.cursor()
sql = "create table if not exists test1(name varchar(128), age int(4))" #
cursor.execute(sql)
#
#cursor =conn.cursor()
sql = "insert into test1(name, age) values ('%s', %d)" % ("zhaowei", 23)
try:
cursor.execute(sql)
except Exception, e:
print e
conn=MySQLdb.Connect(host='localhost',user='root',passwd='')
cursor =conn.cursor()
cursor.execute('create database if not exists student')
#conn.commit()
conn.select_db('student')
cursor =conn.cursor()
sql = "create table if not exists test1(name varchar(128), age int(4))" #
cursor.execute(sql)
#
#cursor =conn.cursor()
sql = "insert into test1(name, age) values ('%s', %d)" % ("zhaowei", 23)
try:
cursor.execute(sql)
except Exception, e:
print e