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

The easiest way to migrate a Django project from MySQL to PostgreSQL(将 Django 项目从 MySQL 迁移到 PostgreSQL 的最简单方法)
本文介绍了将 Django 项目从 MySQL 迁移到 PostgreSQL 的最简单方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将我的 Django 项目的数据库从 MySQL 转换为 PostgreSQL.不幸的是,我不能只使用 Django 的dumpdata"和loaddata"管理命令,因为我的数据库表太大了.我已经阅读了文章 http://www.ofbrooklyn.com/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 http://www.ofbrooklyn.com/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?

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

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

推荐答案

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

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

这篇关于将 Django 项目从 MySQL 迁移到 PostgreSQL 的最简单方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Hibernate reactive No Vert.x context active in aws rds(AWS RDS中的休眠反应性非Vert.x上下文处于活动状态)
Bulk insert with mysql2 and NodeJs throws 500(使用mysql2和NodeJS的大容量插入抛出500)
Flask + PyMySQL giving error no attribute #39;settimeout#39;(FlASK+PyMySQL给出错误,没有属性#39;setTimeout#39;)
auto_increment column for a group of rows?(一组行的AUTO_INCREMENT列?)
Sort by ID DESC(按ID代码排序)
SQL/MySQL: split a quantity value into multiple rows by date(SQL/MySQL:按日期将数量值拆分为多行)