DataX-realize postgresql synchronization data to mysql on Windows

Scenes

DataX- Ali open source offline synchronization tool realizes full and incremental synchronization from Sqlserver to Mysql on Windows:

DataX- Ali Open Source Offline Synchronization Tool Realizes Full and Incremental Synchronization from Sqlserver to Mysql on Windows - Programmer Sought

After the data synchronization from sqlserver to mysql is realized above, the process of data synchronization from postgresql to mysql is the same.

Take the spatial_ref_sys table that saves coordinate system information in the OGC metadata table in PostGis as an example.

 

Create a new table with the same structure in mysql, and synchronize the data of this table in postgresql to the mysql table.

Note:

Blog:
Overbearing rogue temperament blog_CSDN Blog-C#, Architecture Road, Blogger in SpringBoot

accomplish

1. Get the template from postgresqlreader to mysqlwriter

python datax.py -r postgresqlreader -w mysqlwriter

 

2. Copy the json template to the postgresql2mysql.json file

Refer to configuration item documentation

https://github.com/alibaba/DataX/blob/master/postgresqlreader/doc/postgresqlreader.md

DataX/mysqlwriter.md at master · alibaba/DataX · GitHub

Modify the json file to its corresponding url and column information.

{
    "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"
            }
        }
    }
}

Execute synchronous command

python datax.py ./postgresql2mysql.json

Synchronization succeeded

 

Guess you like

Origin blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/130410056