Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error transferring database from MySql to Postgres using mysql2pgsql

In order to host my Python/Django app on Heroku, I'm trying to convert my db from MySQL to Postgres following the instructions on https://realpython.com/blog/python/migrating-your-django-project-to-heroku/. I'm currently running OSX 10.9, and am using the tool mysql2pgsql to make the transfer.

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 hits a snag on auth_user, returning the error "raise Exception('unknown %s' % column['type']) Exception: unknown datetime(6)". This seems strange, because auth_user is generated by one of Django's default installed apps, so I wouldn't expect it to cause any errors.

Any idea what could be causing this error or what I should be doing differently? Thanks.

like image 974
jtimmins Avatar asked Sep 29 '22 19:09

jtimmins


1 Answers

in the directory 'Lib\site-packages\py_mysql2pgsql-0.1.6-py2.7.egg\mysql2pgsql\lib' edit the like 76 postgres_writer.py file as

from

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

to

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

I was facing the same problem, this solution worked for me.

like image 175
javed Avatar answered Oct 07 '22 23:10

javed