使用mysql2pgsql将数据库从MySql传输到Postgres时出错 [英] Error transferring database from MySql to Postgres using mysql2pgsql

查看:1516
本文介绍了使用mysql2pgsql将数据库从MySql传输到Postgres时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了在Heroku上托管我的Python / Django应用程序,我试图将我的数据库从MySQL转换为Postgres,按照 https://realpython.com/blog/python/migrating-your-django-project-to-heroku/ 。我目前正在运行OSX 10.9,并使用mysql2pgsql工具进行传输。



当我尝试运行命令 py-mysql2pgsql -v -f mysql2pgsql.yml 来实际转移数据库,它复制在前三个表,然后在auth_user上点击一个snag,返回错误 raise Exception('unknown%s'%column ['type'])异常:unknown datetime 6)。这似乎很奇怪,因为auth_user是由Django的默认安装应用程序之一生成的,所以我不会指望它会导致任何错误。



任何想法可能导致此错误或我应该做的不同?谢谢。

解决方案

在目录'Lib\site-packages\py_mysql2pgsql-0.1.6-py2.7.egg\ $ p $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $


$ b $ p> elif列['type'] =='datetime':

  elif column ['type'] =='datetime'或column ['type']。startswith('datetime '):

我面临同样的问题,这个解决方案适用于我。


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.

解决方案

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.

这篇关于使用mysql2pgsql将数据库从MySql传输到Postgres时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆