__main__:1: Warning: Unknown table 'employ' 0L
from warnings import filterwarnings
import MySQLdb filterwarnings('ignore', category = MySQLdb.Warning)
#!/usr/bin/env python # -*- coding: UTF-8 -*- import MySQLdb from warnings import filterwarnings filterwarnings('ignore',category = MySQLdb.Warning) #打开数据库连接 db = MySQLdb.connect("localhost","root","","ruiy") #使用cursor()方法获取操作游标 cursor = db.cursor(); #如果数据表已经存在使用execute()方法删除表 cursor.execute("drop table if exists employee") #创建数据表SQL语句 sql = """create table employee ( first_name char(20) not null, last_name char(20), age int, sex char(1), income float )""" cursor.execute(sql) db.close()