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

编程入门 行业动态 更新时间:2024-10-23 18:29:33
本文介绍了将 Django 项目从 MySQL 迁移到 PostgreSQL 的最简单方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想将我的 Django 项目的数据库从 MySQL 转换为 PostgreSQL.不幸的是,我不能只使用 Django 的dumpdata"和loaddata"管理命令,因为我的数据库表太大了.我已经阅读了文章 www.ofbrooklyn/2010/07/18/migrating-django-mysql-postgresql-easy-way/,但似乎要在实践中使用这种方法,我仍然需要将它变成类似在复制模型实例和重置序列时迭代可用模型的管理命令.此外,它似乎也不是很快,因为它会在每个模型实例上发出 save().

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.

有没有更好的迁移方式?实际上,我更喜欢做mysqldump",以某种方式将转储从 MySQL 转换为 PostgreSQL 格式,然后将其加载到 PostgreSQL.您会推荐什么软件来执行这种转储转换并正确地将 MySQL 数据类型转换为 PostgreSQL 数据类型,例如 tinyint(1) 到 boolean?

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?

编辑感谢大家的帮助.我使用 github/maxlapshin/mysql2postgres 实用程序成功迁移了我的数据库.但是,在导入转储后,我仍然必须自己重置生成的 PostgreSQL 数据库中的序列.

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.

推荐答案

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

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

更多推荐

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

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

发布评论

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

>www.elefans.com

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