![](https://img-blog.csdnimg.cn/img_convert/a9bd3e9fa9a8f1bd491aca2ed9fd284e.jpeg)
import pymysql
"""
1、连接本地数据库
2、建立游标
3、创建表
4、插入表数据、查询表数据、更新表数据、删除表数据
"""
def create_table():
#连接本地数据库
db = pymysql.connect("localhost","root","123456","test")
#创建游标
cursor = db.cursor()
#如果存在student表,则删除
cursor.execute("DROP TABLE IF EXISTS student")
#创建student表
sql = """
create table stu