0

I am using a function to migrate data between mongo and oracle. This function takes as input 3 arguments: the connection to mongo, the connection to oracle and the entity of the mongo database which I am using as key in mongo. I am looping through a list of entities so the code looks as this one:

def move_data( engine, mongo_conn, entity ):
    # do stuff here
    # Create a pandas df
    df.to_sql( ... )


if __name__ == “__main__”:
     for entity in entity_list:
         move_data( engine, mongo_conn, entity )

Is there a way to parallelize this for loop? It is not possible for me to use python3 for this task.

user3666197
  • 1
  • 6
  • 50
  • 92
Skynet
  • 1
  • 1
    "Is there a way to parallelize this for loop?" Yes. I suggest you google "python parallel programming" to get an idea of how to approach the problem. As your post is right now, it is too broad and we can't easily answer it in the format expected on this site. – Code-Apprentice May 22 '20 at 21:34
  • Threading is the keyword here, I guess. See https://www.tutorialspoint.com/python/python_multithreading.htm – Rennnyyy May 22 '20 at 21:36
  • For more of a hint, I suggest looking at coroutines. They might give you what you need without the complexity of full on threading. – Code-Apprentice May 22 '20 at 22:05

0 Answers0