I have a code as follows:
import pg
import MySQLdb
db_postgre = pg.connect(dbname=...,user=...,passwd=...,host=.., port=...)
db_mysql=MySQLdb.Connect(user=...,passwd=...,db=..., host=...)
cur = db_mysql.cursor(MySQLdb.cursors.DictCursor)
cur.execute ("""SELECT X,Y,Z FROM tab_a""")
data = crs.fetchall ()
for row in data :
#INSERT THE ROW (X,Y,Z) TO POSTGRESQL TABLE.
The table in PostgreSQL (post_tab_a) is identical to the one in MySQL .
meaning it also has X,Y,Z
all types are TEXT.
Is it possible to perform insert directly from cur? What is the easiyest way to do this insert?
insert into post_tab_a (x,y,z) select x,y,z from tab_a. The issue is that post_tab_a is in postgresql and tab_a is in MYSql