To perform batch conversion or call conversion procedure from an automation script you can use console version of MySQL to PostgreSQL converter called S2PAGENT.EXE. Find this file in the installation folder. You can either run this tool directly from command line or call it from any script as well. The program supports the following command-line options:
--dest=... | PostgreSQL database name or script file | |
--dump | convert MySQL database into PostgreSQL file | |
--help | display help message and exit | |
--logfile=... | path to the logfile where execution traces will be written | |
--mode=... | how to process existing PostgreSQL database (0 - overwrite the entire database, 1 - overwrite existing tables only, 2 - skip existing tables, 3 - merge) | |
--myport=... | MySQL port | |
--mysqlh=... | MySQL server IP address or network name | |
--mysqlu=... | MySQL user name | |
--mysqlp=... | MySQL user password | |
--no_schema | do not include schema name in table name | |
--pgport=... | PostgreSQL port | |
--posgsh=... | PostgreSQL server IP address or network name | |
--posgsu=... | PostgreSQL user name | |
--posgsp=... | PostgreSQL user password | |
--profile=... | path to the file to load conversion settings from | |
--silent | use this option to disable program output | |
--skip_idx | skip converting indexes | |
--src=... | MySQL database name | |
--tab_def | convert table definitions only | |
--tab_file=... | file containing table names to convert (one table name per line) |
In the following example the program converts all tables from MySQL database "mysql_db" into PostgreSQL database "pgs_db":
S2PAGENT.EXE --src="mysql_db" --posgsu=postgres --posgsp=qwerty --dest="pgs_db" --mysqlh=mysqlhost --mysqlu=administrator --mysqlp=the_passsword
Notes: