'Importing postgres data to mysql

I have a requirement where I need to insert the postgres data into mysql. Suppose I have user table in postgres. I have user table also in mysql. I tried to do something like this:

gts = 'cd '+js_browse[0].js_path #gts prints correct folder name/usr/local/myfolder_name 
os.system(gts)
gts_home = 'export GTS_HOME='+js_browse[0].js_path  
os.system(gts_home)
tt=gts+'&& sh bin/admin.sh User --input-dir /tmp/import'
#inside temp/import i import store my postgres user table data
#bin is the folder inside myfolder_name

In mysql if I use the command it works perfectly fine:

cd /usr/local/myfolder_name
bin/admin.sh User -account=1 user=hamid -create'

I am unable to store data inside mysql this way. Any help shall be appreciated.



Solution 1:[1]

You don't really give us much information. And why would go from postgres to mysql?

But you can use one of these tools - I have seen people talk good about them

pg2mysql or pgs2sql

Hope it works out.

Solution 2:[2]

PostgreSQL provides possibility to dump data into the CSV format using COPY command.

The easiest path for you will be to spend time once to copy schema objects from PostgreSQL to MySQL, you can use pg_dump -s for this on the PostgreSQL side. IMHO, it will be the biggest challenge to properly move schemas.

And then you should import CSV-formatted data dumps into the MySQL, check this for reference. Scrolling down to the comments you'll find recipes for Windows also. Something like this should do the trick (adjust parameters accordingly):

LOAD DATA LOCAL INFILE C:\test.csv
INTO TABLE tbl_temp_data 
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n';

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mads
Solution 2 vyegorov