py3和mysql_mysql和Python3 连接 pymysql 模块

#安装模块:pip install pymysql

import pymysql

conn=pymysql.connect(host='127.0.0.1',port=3306, user='root', passwd='12345qq',db='project')

#建立连接

host:'127.0.0.1,不用联网也可访问数据库

port:2206

user:登录mysql的用户名,可以通过 select user(); 语句查看用户名

passwd: 密码

db:要连接的数据库名称

cur=conn.cursor() #建立游标

cur.execute('select * from project.wc limit 5') #execute方法执行select语句

for r in cur.fetchall():

print(r)

cur.close() #关闭

conn.close()

#输出:

('767', 33, '', 'Absolutely wonderful - silky and sexy and comfortable', 4, 1, 0, 'Initmates', 'Intimate', 'Intimates')

('1080', 34, '', 'Love this dress! it\'s sooo pretty. i happened to find it in a store, and i\'m glad i did bc i never would have ordered it online bc it\'s petite. i bought a petite and am 5\'8". i love the length on me- hits just a little below the knee. would definitely be a true midi on someone who is truly petite.', 5, 1, 4, 'General', 'Dresses', 'Dresses')

('1077', 60, 'Some major design flaws', 'I had such high hopes for this dress and really wanted it to work for me. i initially ordered the petite small (my usual size) but i found this to be outrageously small. so small in fact that i could not zip it up! i reordered it in petite medium, which was just ok. overall, the top half was comfortable and fit nicely, but the bottom half had a very tight under layer and several somewhat cheap (net) over layers. imo, a major design flaw was the net over layer sewn directly into the zipper - it c', 3, 0, 0, 'General', 'Dresses', 'Dresses')

...

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值