Use python to operate mysql database (bulk insert data)
#! / usr/bin/env python#-*-coding: utf-8-*-import MySQLdb# establish a connection conn = MySQLdb.connect (host='127.0.0.1',user='root',passwd='1qaz#EDC',db='test_db') cur = conn.cursor () # manipulate the data li = [('tanzhenx','shaoguan'), (' huangmengdie','shaoguan')] # define a list containing multiple tuples Cur.executemany ('insert into user (name,address) values (% s)', li) # bulk insert data conn.commit () # submit request in each tuple, otherwise the data will not be written to the database # close database connection cur.close () conn.close ()