当前位置: 首页 > 工具软件 > mysql2psql > 使用案例 >

py mysql2pgsql_Python py-mysql2pgsql包_程序模块 - PyPI - Python中文网

韦绍晖
2023-12-01

用法:

寻求帮助?> py-mysql2pgsql -h

usage: py-mysql2pgsql [-h] [-v] [-f FILE]

Tool for migrating/converting data from mysql to postgresql.

optional arguments:

-h, --help show this help message and exit

-v, --verbose Show progress of data migration.

-f FILE, --file FILE Location of configuration file (default:

mysql2pgsql.yml). If none exists at that path,

one will be created for you.

别担心这是你第一次,会很温柔的。> py-mysql2pgsql

No configuration file found.

A new file has been initialized at: mysql2pgsql.yml

Please review the configuration and retry...

如输出所示,我的文件是在mysql2pgsql.yml为您创建的

编辑。对于不耐烦的人,这里是文件中包含的内容。# if a socket is specified we will use that

# if tcp is chosen you can use compression

mysql:

hostname: localhost

port: 3306

socket: /tmp/mysql.sock

username: mysql2psql

password:

database: mysql2psql_test

compress: false

destination:

# if file is given, output goes to file, else postgres

file:

postgres:

hostname: localhost

port: 5432

username: mysql2psql

password:

database: mysql2psql_test

# if only_tables is given, only the listed tables will be converted. leave empty to convert all tables.

#only_tables:

#- table1

#- table2

# if exclude_tables is given, exclude the listed tables from the conversion.

#exclude_tables:

#- table3

#- table4

# if supress_data is true, only the schema definition will be exported/migrated, and not the data

supress_data: false

# if supress_ddl is true, only the data will be exported/imported, and not the schema

supress_ddl: false

# if force_truncate is true, forces a table truncate before table loading

force_truncate: false

很好的自我解释对吧?有几件事要注意,首先如果

目的地->文件已填充所有输出将转储到

指定位置,无论目的地中包含什么内容。

博士后。所以如果你想直接转储到你的服务器

文件的值为空

假设你有一个mysql数据库,有很多很多表,但是你只是

有兴趣导出这些表的子集,没问题。仅添加

您只想包含在表中的表

不希望导出到排除表。

其他感兴趣的项目可能是跳过移动数据而只创建

模式,反之亦然。跳过数据并仅创建架构

将“抑制数据”设置为“真”。只迁移数据而不重新创建

表设置SuxPixDDL >true;如果存在现有数据

在将setforce\u truncate导入到

正确。当设置为

错误。

最后一件事,–verbose标志没有它,工具就会消失

在这条快乐的道路上,没有任何输出打扰你,直到

完成。有了它,你将得到一个剧本一个剧本的摘要

打开。这里有一个例子> py-mysql2pgsql -v -f mysql2pgsql

START PROCESSING table_one

START - CREATING TABLE table_one

FINISH - CREATING TABLE table_one

START - WRITING DATA TO table_one

24812.02 rows/sec [20000]

FINISH - WRITING DATA TO table_one

START - ADDING INDEXES TO table_one

FINISH - ADDING INDEXES TO table_one

START - ADDING CONSTRAINTS ON table_one

FINISH - ADDING CONSTRAINTS ON table_one

FINISHED PROCESSING table_one

START PROCESSING table_two

START - CREATING TABLE table_two

FINISH - CREATING TABLE table_two

START - WRITING DATA TO table_two

FINISH - WRITING DATA TO table_two

START - ADDING INDEXES TO table_two

FINISH - ADDING INDEXES TO table_two

START - ADDING CONSTRAINTS ON table_two

FINISH - ADDING CONSTRAINTS ON table_two

FINISHED PROCESSING table_two

 类似资料: