可以使用JSON配置的数据迁移
magnivore的Python项目详细描述
镁铁矿
一个数据迁移工具,使整个数据库的迁移简单到 编写json迁移规则。 支持mysql、sqlite和postgres。
快速查看
一个简单的迁移规则:
{ "profiles": { "sources": [ {"table": "users"}, {"table": "addresses", "on":"user"} ], "transform": { "name": "username", "city": "addresses.city" } } }
这会将数据迁移到profiles表,使用来自用户的数据并加入 地址。在transform部分,我们指定实际需要的字段 迁移。
在这种情况下,users.username将迁移到name和addresses.city 到city。
安装
确保您有必要的数据库驱动程序。你需要 postgres的psycopg和mysql的pymysql
从PIP安装:
pip install magnivore
配置Magnivore。您可以使用以下命令生成骨架配置文件:
magnivore config-skeleton
初始化Magnivore:
magnivore init
打个招呼:
magnivore hello
您已成功安装Magnivore!现在可以编写迁移规则和 使用以下命令执行它们:
magnivore run myrules.json
故障排除
目前对包含破折号的表名的支持不足,因此请确保 你的表名没有破折号。