首页 > 数据库技术 > 详细

python & MySQLdb(Three)

时间:2018-11-03 18:38:30      阅读:140      评论:0      收藏:0      [点我收藏+]

mmp我搞了半天发现是在做字符串的转换,这个是必然报错的,但是我们用连接操作就可以了,利用MySQLhelper的get_one方法去传就可以了,自己真的菜啊看来

#方法一:
#encoding=utf8
from fengzhaung import *
ih=input("输入编号")
print(id(ih))
sql="select * from stu where stu_id="+ih
helper=MysqlHelper(192.168.65.146,3306,student,root,toor)
s=helper.get_one(sql)
print(s)
#方法二
#encoding=utf8
from fengzhaung import *
ih=input("请输入编号:")
sql="select * from stu where stu_id=%s"
param=[ih]
helper=MysqlHelper(‘192.168.65.146‘,3306,‘student‘,‘root‘,‘toor‘)
s=helper.get_one(sql,param)
print(s)

python & MySQLdb(Three)

原文:https://www.cnblogs.com/kk328/p/9901633.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!