Error transferring database from MySql to Postgres using mysql2pgsql

To host my Python / Django app in Heroku, I am trying to convert my db from MySQL to Postgres according to the instructions https://realpython.com/blog/python/migrating-your-django-project-to-heroku/ . I am currently running OSX 10.9, and I am using the mysql2pgsql tool to migrate.

When I try to run the command " py-mysql2pgsql -v -f mysql2pgsql.yml " to actually transfer the db, it copies over the first three tables and then falls into the auth_user trap, returning the error " raise Exception('unknown %s' % column['type']) Exception: unknown datetime(6) ". This seems strange because auth_user is generated by one of the default Django applications, so I did not expect it to cause any errors.

Any idea what might cause this error or what should I do differently? Thank you

+5
source share
1 answer

in the directory "lib \ site-packages \ py_mysql2pgsql-0.1.6-py2.7.egg \ mysql2pgsql \ lib" edit the file 76 postgres_writer.py a

of

  elif column['type'] == 'datetime': 

to

 elif column['type'] == 'datetime' or column['type'].startswith('datetime('): 

I ran into the same problem, this solution worked for me.

+4
source

Source: https://habr.com/ru/post/1203272/


All Articles