当前位置:Gxlcms > 数据库问题 > 用python链接mysql

用python链接mysql

时间:2021-07-01 10:21:17 帮助过:18人阅读

localhost" user = "root" password = "000000" database = "lightning" db=pymysql.connect(server, user, password, database) #使用cursor()方法创建一个游标对象cursor cursor =db.cursor() #使用execute()方法执行SQL查询 #str="INSERT INTO `lightning`.`lightning_count` (`pic_Name`, `sex`, `start_time`, `end_time`, `intensity`, `start_longitude`, `start_latitude`, `end_longitude`, `end_latitude`, `x0`, `y0`, `x1`, `y1`) VALUES (‘D:/002.png‘, ‘I‘, ‘2020-06-22 19:56:10.156‘, ‘2020-06-22 19:56:10.856‘, ‘13999‘, ‘35.987000‘, ‘42.578000‘, ‘36.786000‘, ‘44.562000‘, ‘100‘, ‘100‘, ‘200‘, ‘200‘);" #cursor.execute("use lightning;") cursor.execute("INSERT INTO lightning.lightning_count (Id) VALUES (3)") cursor.connection.commit()#执行commit操作,插入语句才能生效 #使用fetchone()方法获取单条数据,并打印 #data =cursor.fetchone() #print("Datebase version : %s " % data) #关闭数据库连接 db.close()

 

用python链接mysql

标签:解决   编译器   start   comm   cal   art   datebase   %s   commit   

人气教程排行