Error transferring database from MySql to Postgres using mysql2pgsql

别等时光非礼了梦想. 提交于 2019-12-09 18:24:21

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/26008398/error-transferring-database-from-mysql-to-postgres-using-mysql2pgsql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!