pymysql 增删改 查 索引

pymysql 模块的使用

pip install pymysql

username = input ("请输入用户")

pwd = input ("请输入密码")

#建立连接

conn = pymysql.connect(

host = "localhost",

user = "root",

password = "",

database= "db8",

port = 3306,

charset = "utf8")

#创建游标

cur = conn.cursor()

sql = "select * from userinfo where name = '%s' and pwd = '%s'" % (username,pwd)

print (sql)

res = cur.execute(sql)#光标执行sql

print(res)#成功返回1

cur.close()

conn.close()

if res:

print("登录成功")

else:

print("登录失败")

索引传送:https://www.cnblogs.com/majj/p/9196025.html

pymysql 增删改 查传送:https://www.cnblogs.com/majj/p/9180353.html

原文地址:https://www.cnblogs.com/zhangqing979797/p/9811493.html