A
A
Andrey2018-02-01 16:21:26
MySQL
Andrey, 2018-02-01 16:21:26

Syntax error: How to migrate from MySQL to Postgres?

There is a MySQL database dump - dump.sql , which was given to me by third-party developers. Encoding - cp1251 .
You need to migrate it to postgresql .
What I do:
1) I restore the dump to the database (the developers unload it in their own way, so I decided to do the dump myself)
2) I make my own dump

mysqldump --compatible=postgresql -u root catalog > dump.sql

3) I convert the dump for postgresql (I know that this is just a text file, but nevertheless it was not possible to simply restore from sql)
I do this with the utility https://github.com/lanyrd/mysql-postgresql-converter
python db_converter.py dump.sql pg_dump
4) I try to restore psql pg_database < pg_dump
On at the moment there is this error
START TRANSACTION
SET
SET
SET CONSTRAINTS
invalid command \"?????????
ERROR:  syntax error at or near "0"
LINE 5:     "price" float NOT NULL DEFAULT '0',
                                            ^

Tell me what's the problem? how to fix such errors?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
terrier, 2018-02-01
@terrier

Well, apparently this cryptic python script of yours does not take into account all the differences between mysql and psql, so even if you fix this particular error (remove the quotes), a bunch of others will come out.
I would recommend using one of the more proven tools to convert the dump.

K
Konstantin Tsvetkov, 2018-02-01
@tsklab

I do this with the utility https://github.com/lanyrd/mysql-postgresql-converter

invalid command \"?????????
Encoding is not correct.
--default-character-set=utf8

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question