使用python做登陆程序,在数据库中查找用户名和密码是否正确,用SQLite

使用python做登陆程序,在数据库中查找用户名和密码是否正确用SQLite

import MySQLdb
conn=MySQLdb.connect(user='root',passwd='pwd',host='127.0.0.1',db='python_test')
cur=conn.cursor()
cur.execute("select * from users where uid='101' and login='ong'")
##uid 是你的密码 ;login是你的用户名
num=0
for data in cur.fetchall():
num=num+1
print data
if(num != 0):
print '登陆成功'
else:
print '用户名或密码未找到'
cur.close()
conn.commit()
conn.close()

如果还有其他问题可以再问
温馨提示:答案为网友推荐,仅供参考
相似回答