将Django项目从MySQL迁移到PostgreSQL的最简单的方法

编程入门 行业动态 更新时间:2024-10-23 16:18:38
本文介绍了将Django项目从MySQL迁移到PostgreSQL的最简单的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我想把Django项目的数据库从MySQL转换成PostgreSQL。不幸的是,我不能仅仅使用Django的dumpdata和loaddata管理命令,因为我的数据库表太大了。我已经阅读了 http:// www .ofbrooklyn / 2010/07/18 / migrating-django-mysql-postgresql-easy-way / ,但是在实践中似乎使用这种方法,我仍然需要将其变成管理命令在复制模型实例时以及重置序列时迭代可用模型。此外,它似乎不是很快,因为它在每个模型实例上发出save()。

有更好的迁移方式吗?其实我更喜欢做mysqldump,把转储从MySQL转换成PostgreSQL格式,然后加载到PostgreSQL。你推荐哪个软件可以执行这样的转储转换,并从MySQL数据类型正确转换为PostgreSQL,例如tinyint(1)到boolean?

编辑感谢大家的帮助。我使用 github/maxlapshin/mysql2postgres 实用程序成功地迁移了我的数据库。然而,在导入转储后,我仍然需要自己重新生成PostgreSQL数据库中的序列。

解决方案

有几个转换器,例如Ruby中的一个: github/maxlapshin/mysql2postgres

I would like to convert my Django project's database from MySQL to PostgreSQL. Unfortunately, I can't just use Django's "dumpdata" and "loaddata" management commands because my database tables are too big. I already read the article www.ofbrooklyn/2010/07/18/migrating-django-mysql-postgresql-easy-way/, but it seems that to use this method in practice I'll still need to turn it into something like a management command that iterates over available models when it copies model instances and when resets sequences. Besides, it doesn't seem very fast either because it issues save() on each model instance.

Is there a better way to migrate? Actually, I would prefer to do "mysqldump", convert the dump from MySQL to PostgreSQL format somehow and then load it to PostgreSQL. What piece of software would you recommend that could perform such dump conversion and correctly convert from MySQL data types to PostgreSQL ones, for example tinyint(1) to boolean?

Edit Thanks everyone for your help. I successfully migrated my database using github/maxlapshin/mysql2postgres utility. However, I still had to reset sequences in the resulting PostgreSQL database myself after importing the dump.

解决方案

There are several converters for it, for example this one in Ruby: github/maxlapshin/mysql2postgres

更多推荐

将Django项目从MySQL迁移到PostgreSQL的最简单的方法

本文发布于:2023-10-15 01:05:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1492787.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:最简单   方法   项目   Django   PostgreSQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!