Slow MySQL Inserts from Python -



Slow MySQL Inserts from Python -

i'm trying insert info mysql database using python (pymysql connector) , i'm getting poor performance (around 10 rows inserted per second). table innodb, , i'm using multiple values insert statement , have ensured autocommit turned off. ideas why inserts still slow?

i thought autocommit wasn't beingness disabled i've added code test disabled (=0) during each connection.

here illustration code:

for in range(1,500): params.append([i,i,i,i,i,i]) insertdb(params) def insertdb(params): query = """insert test (o_country_id, i_country_id,c_id,period_id,volume,date_created,date_updated) values (%s,%s,%s,%s,%s,now(),now()) on duplicate key update trade_volume = %s, date_updated = now();""" db.insert_many(query,params) def insert_many(query,params=none): cur = _connection.cursor() try: _connection.autocommit(false) cur.executemany(query,params) _connection.commit() except pymysql.error, e: print ("mysql error %d: %s" % (e.args[0], e.args[1])) cur.close()

what else issue? above illustration takes eternity of 110 seconds execute.

not sure wrong, seek mysqldb and/or mysql connector modules instead , see if same performance numbers.

python mysql innodb pymysql

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -