景泽元的编程 2019-12-24
安装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))