I have a table "control" like this in local mysql (IP = 192.168.137.165)
Card_ID     Time_in      Time_out     Index
  101         7:00         11:00       0
  102         7:15         11:00       1
  103         6:45         12:00       1
Local and remote tables "control" are the same table
How to select all rows with index = 1 and insert to remote mysql using python? (IP=192.168.137.1)
I have ideas for backup database. If remote mysql alive, index = 0 and if remote mysql die, index = 1.
And if remote re-connect, I want to send data in local mysql to remote.So I want to just want to insert the line with index = 1
Code connect and insert mysql
import MySQLdb
db_local = MySQLdb.connect("localhost","root","loot","luan_van")
db = MySQLdb.connect("192.168.137.1","root_a","","luan_van")
def add_remote():
   with db:
       cur = db.cursor()
       cur.execute("INSERT INTO control(Card_ID,Time_in) VALUES ('%d', NOW())" %num)
       return
I can insert simple but I don't know insert multi-rows. Please help me. Thanks.
 
    