I've the following list of queries:
queries = ["SELECT * FROM db.trans", "SELECT * FROM db.order", "SELECT * FROM db.account UNION ALL SELECT * FROM db.account2", "SELECT * FROM db.trans UNION ALL SELECT * FROM db.trans2"]
And using my database connection I am trying to run all this queries in parallel instead of:
for query in queries:
cursor.execute(query)
I'm trying to use multiprocessing library and my current code is:
import multiprocessing
def work():
for query in queries:
cursor.execute(query)
if __name__ == '__main__':
_p = multiprocessing.Process(target=work)
_p.start()
_p.join()
However, it is taking the same time as the sequential mode... anyone knows how to run a parallel processing?
Thanks!