场景
DataX-阿里开源离线同步工具在Windows上实现Sqlserver到Mysql全量同步和增量同步:
https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/130330353
在上面实现sqlserver到mysql的数据同步之后,如果要实现postgresql到mysql数据同步流程一样。
以PostGis中的OGC元数据表中的保存坐标系统信息的spatial_ref_sys表为例。
在mysql中新建同样结构的表,将postgresql中这个表的数据同步到mysql的表中。
注:
博客:
https://blog.csdn.net/badao_liumang_qizhi
实现
1、获取postgresqlreader到mysqlwriter的模板
python datax.py -r postgresqlreader -w mysqlwriter
2、复制json模板到postgresql2mysql.json文件
参考配置项说明文档
https://github.com/alibaba/DataX/blob/master/postgresqlreader/doc/postgresqlreader.md
https://github.com/alibaba/DataX/blob/master/mysqlwriter/doc/mysqlwriter.md修改json文件为自己对应的url和列等信息。
{ "job": { "content": [ { "reader": { "name": "postgresqlreader", "parameter": { "connection": [ { "jdbcUrl": [ "jdbc:postgresql://127.0.0.1:5432/数据库名" ], "table": [ "spatial_ref_sys" ] } ], "password": "密码", "username": "postgres", "column": [ "srid", "auth_name", "auth_srid", "srtext", "proj4text", ] } }, "writer": { "name": "mysqlwriter", "parameter": { "column": [ "srid", "auth_name", "auth_srid", "srtext", "proj4text", ], "connection": [ { "jdbcUrl": "jdbc:mysql://127.0.0.1:3306/数据库名?useUnicode=true&characterEncoding=gbk", "table": [ "spatial_ref_sys" ] } ], "password": "密码", "preSql": [ "delete from spatial_ref_sys" ], "session": [], "username": "root", "writeMode": "insert" } } } ], "setting": { "speed": { "channel": "5" } } } }
执行同步命令
python datax.py ./postgresql2mysql.json
同步成功
标签:同步,postgresql,Windows,postgresqlreader,DataX,mysql,mysqlwriter From: https://www.cnblogs.com/badaoliumangqizhi/p/17359389.html