import data to a database from another database in python
Question: I have two databases, one is located in localhost, the other one in located in
another server.

In python, I want to import some data from database 2 to database 1:

    
    
      con1 = mdb.connect (host= xx, user=xx, passwd= xx, db= xx) //connect database 1
      cur1 = con1.cursor()
      con2 = mdb.connect (host= xx, user=xx, passwd= xx, db= xx) //connect database 2
      cur2 = con2.cursor()
    
      query = "update database1.table1 set area = (select database2.table2.area from database2.table2)"
    
      cur(1 or 2?).execute(query) //Don't know how to solve this problem
    


Answer: No, you can't do cross-server operations like that.

  1. Fetch your data from source database (in batches, if it's big)

  2. Prepare and send update statements to target database.

