Pymysql
2022-07-05
pip3 install pymysql
import pymysql
pymysql.connect(
host = '10.0.0.1',
port=3306,
user='root',
password='123',
db='db1',
charset='utf-8'
)
cursor = conn.cursor()
sql='select * from userinfo where user="%s" ans pwd = "%s"' %(user,pwd)
print(sql)
rows=cursor.execute(sql)
cursor.close()
conn.close()
if rows:
print('登录成功')
else:
print('no')
Pymysql 模块只 sql 注入问题
sql='select * from userinfo where user=%s ans pwd = %s'
print(sql)
rows=cursor.execute(sql,(user,pwd)) # 改成这样写;