python3连接数据库mysql,并进行查询
安装navicat for mysql,参考:https://www.jianshu.com/p/2494e02caf63
import pymysqlecshop=pymysql.connect(‘localhost‘,‘root‘,‘root‘,‘ecshop‘) #连接数据库cus=ecshop.cursor() #创建游标对象cus.execute("SELECT VERSION()") #执行sql查询#print(dir(cus))datas=cus.fetchone() #获取单条数据print(datas)ecshop.close() #关闭数据库#print(dir(ecshop))
相关推荐
辛苦的字幕君小样 2011-11-10
scjcjlu 2016-03-06
klshige 2019-06-25
会写code的凳子哥 2013-03-23
蔷薇部落 2013-03-10
langqiao 2013-01-09
88284453 2012-01-11
Balalala 2011-04-05
levysnail 2011-03-08
yixiaoqi00 2011-03-30
jsxin0 2017-11-08
bruceli 2014-06-19
BusyMonkey 2018-10-22
Letitgo 2013-02-19
的砖栏 2019-04-13
phpcrazy 2019-04-12
YClimb 2019-04-12
phpyounger 2019-04-11