import pymysql
user = input('username:')
pwd = input('password:')
conn = pymysql.connect(host='localhost',user='root',password='',database='db1')
cursor = conn.cursor()
sql = "select * from userinfo where user=%s and password=%s"
# sql = "select * from userinfo where user=%(u)s and password=%(p)s"
cursor.execute(sql,[user,pwd])
# cursor.execute(sql,{'u':user,'p':pwd})
ret = cursor.fetchone()
cursor.close()
conn.close()
if ret:
print('登陆成功!')
else:
print('登陆失败!')