您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

pymysql模块之基本使用

bubuko 2022/1/25 19:59:12 mysql 字数 931 阅读 618 来源 http://www.bubuko.com/infolist-5-1.html

#pip3 install pymysqlimport pymysqluser=input('user>>: ').strip()pwd=input('password>>: ').strip()# 建立链接conn=pymysql.connect( host='198.168.43.122', p ...
#pip3 install pymysql
import pymysql

user=input(‘user>>: ‘).strip()
pwd=input(‘password>>: ‘).strip()

# 建立链接
conn=pymysql.connect(
host=‘198.168.43.122‘,
port=3306,
user=‘root‘,
password=‘123‘,
db=‘db9‘,
charset=‘utf8‘
)

# 拿到游标
cursor=conn.cursor()

# 执行sql语句

sql=‘select * from userinfo where user = "%s" and pwd="%s"‘ %(user,pwd)
rows=cursor.execute(sql)

cursor.close()
conn.close()

# 进行判断
if rows:
print(‘登录成功‘)
else:
print(‘登录失败‘)

pymysql模块之基本使用

原文:https://www.cnblogs.com/huahuawang/p/12662806.html


如果您也喜欢它,动动您的小指点个赞吧

除非注明,文章均由 laddyq.com 整理发布,欢迎转载。

转载请注明:
链接:http://laddyq.com
来源:laddyq.com
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。


联系我
置顶