python操作pymysql
#_author:来童星#date:2019/12/19import pymysql#1.打开数据库连接db=pymysql.connect(‘localhost‘,‘root‘,‘root‘,‘test‘)#2.使用cursor()方法创建一个游标对象cursor=db.cursor()#3.使用execute()方法执行SQL查询cursor.execute(‘select verson()‘)#4.使用fetchone方法获取单条数据data=cursor.fetchone()print(‘database version is : %s‘%data)#5.关闭数据库连接db.close()
相关推荐
  pythonxuexi    2019-12-16  
   暗夜之城    2019-11-13  
   愿天下再无BUG    2020-06-25  
   阿亮    2020-06-22  
   liuweiq    2020-06-14  
   variab    2020-06-14  
   CloudXli    2020-06-04  
   sunnyxuebuhui    2020-06-04  
   JamesRayMurphy    2020-05-31  
   测试自动化顾问    2020-05-29  
   heniancheng    2020-05-26  
   huolan    2020-05-12  
   kuwoyinlehe    2020-05-07  
   zjyhll    2020-05-06  
   huangliang00    2020-05-03  
   sulindong0    2020-04-30  
   探索世界改变世界    2020-04-21