分类:pymysql
代码如下#-*-coding=utf-8-*-#@time:2020/5/28/02821:00#Author:cyx#@File:插入数据.py#@Software:PyCharmimportpymysqlcon=pymysql.connect(host='localhost',user='root',password='123456',database='python_db',port=3366)#创建游标对象cur=con.cursor()#编写插入数据的sqlsql='insertintot_student(sname,age,score)values(%s,%s,%s)'try:#执行sqlcur.executemany(sql,[('小楚',21,99.9),('小刘',...
继续阅读 >
2020
09-29
我就废话不多说了,大家还是直接看代码吧!importpymysql,hashlib结果:单条结果{'id':1,'name':'打车','phone':'132453'}sql='select*fromzxj'defop_mysql(sql,many=True):db_info={'user':'jxz','password':'123456','host':'118*******','db':'jxz','port':3306,'charset':'utf8','autocommit':True}conn=pymysql.connect(**db_info)#建立连接cur=conn.cursor(pymysql.cursors.DictCurs...
继续阅读 >
2020
09-24
咱还是直接看代码吧!frompymysqlimport*defmain():#创建connection连接conn=connect(host='',port=3306,database='',user='',password='',charset='utf8')#获取cursor对象cs1=conn.cursor()#执行sql语句query='insertinto表名(列名1,列名2,列名3,列名4,列名5,列名6)values(%s,%s,%s,%s,%s,%s)'列名1=值1列名2=值2列名3=值3列名4=值4列名5=值5列名6=...
继续阅读 >