pymysql的增删改
时间:2021-07-01 10:21:17
帮助过:3人阅读
pymysql
username=input(
‘请输入用户名:‘)
pwd=input(
‘请输入密码:‘)
pymysql.connect()
# 创建连接
conn=
pymysql.connect(
host=
‘127.0.0.1‘,
# localhost
user=
‘root‘,
password=
‘‘,
database=
‘db2‘,
port=3306
,
charset=
‘utf8‘
)
# 创建游标
cur=
conn.cursor()
sql =
"insert into userinfo(name,pwd) values (%s,%s)"
print(sql)
res=
cur.execute(sql,[username,pwd])
print(res)
# 增,删,改 一定要加commit
conn.commit()
# 关闭游标
cur.close()
conn.close()
pymysql的增删改
标签:exec imp com put char int mys database 输入