Here is a simple method for you to write a batch of data in MYSQL Executenamy.
Examples:
if isinstance(item,MmzItem): data = {'xinxi':item['xinxi']} xinxia = data['xinxi'] print(len(xinxia),type(xinxia)) #print("ffffffffffffff",xinxi[0],xinxi[0][8]) try: con.executemany('insert ignore into xi(zhi,gon,go,gon1,nian2,di2,xue2,jin2,rq2,w2z)values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)',xinxia) except pymysql.Error as e: print(e) connect.rollback() connect.close() sys.exit(0) connect.commit() connect.close() #connect.commit() print("Saving.........................")
Similar Posts:
- pymysql.err.OperationalError: (1054, “Unknown column’aa’in’field list’)
- [Solved] Python pymysql.err.OperationalError: (2013, ‘Lost connection to MySQL server during query…
- mysql Column count doesn’t match value count at row 1
- [Solved] mybatis Bulk Insert Error: Column count doesn‘t match value count at row 1
- How to Solve MYSQL Error: pymysql.err.InterfaceError: (0, ”)
- How to solve the problem of potentially unsupported type in Python sqllite
- MySQL database insert into statement with parameters Error
- How to Solve Python socket:[Errno 32] Broken pipe
- Solve Python MySQL insert int data error: typeerror% d format: a number is required, not str
- Commands out of sync; you can’t run this command now