currently i am working on the python project that connects to mysql database using pymysql library of python. i have to insert around 5000 rows using stored procedure present in database.but for a single row insertion it is taking 1-2 seconds(via python code).below is this function(you can assume that connection has succesfully made)
def execute_write_stored_procedure(self, procedure_name, args=None):
try:
with self.connection.cursor() as cursor:
cursor.callproc(procedure_name, args)
self.connection.commit()
return True
except Exception as e:
print(e)
#raising error in case of any error
raise Exception(f"Errorn in execute_write_stored_procedure function : {e}") from e
for loop for row insertion :
for row in rows:
execute_write_stored_procedure('procedure_name',row)
i have checked the database and each and every row has a successfull insertion,but is taking too long .i don’t know how to solve this, because this is bare minimum code you can have.note that this is single row insertion alogrithm, stored procedure is not designed for bulk insert, although i have tried all the possible libraries like pymysql,cymysql,mysqldb i have tried multithreading, pooling, pymysql.executemany but none of them worked.any help would be appricieted!!