支持的文件格式
- gz
- zip
- sql
分割 SQL
调用方式
from pathlib import Path
# absolute_file_path 读取文件的绝对路径
# absolute_out_put_folder 输出的文件夹的绝对路径
# 返回的 任务ID
task_id = SliceFactory.slice(absolute_file_path=Path("D:\\workspace\\Resources\\eclinical_edc_prod_21_20230630025243.sql.gz"),
absolute_out_put_folder=Path("YYYYY"))
输出的结果
| YYYYY | 输出的文件夹 |
| cdfe5a8a9811459d9b0a940aa86abd89 | 根据任务 ID 生成的对应文件夹 |
| CREATE | 创建 表单的 SQL 语句 |
| INSERT | 插入 表单数据的 SQL 语句 |
| file_list.json | 生成的文件信息 |
SQL 文件名的格式:{表名}-{uuid}
获取 SQL 文件信息
# where SQL 文件夹的绝对路径
file_list = FileInfoList(
where=Path("D:\\aws\\eclinical40_auto_testing\\slicing\\src\\slicing\\XXXX\\89f20cdac717425091fb0fb9220481fe"))
文件信息
| sql_type | CREATE(创建表单) 或 INSERT(插入数据) |
| name | 文件的全名 {table 或 view 或 index 或 procedure}-{id} |
| table | 表名 |
| id | uuid |
| size | 文件大小,单位字节 |
| no | SQL 的顺序编号 |
| view | 视图名 |
| procedure | 存储过程名 |
| index | 索引名 |
| operation_object | 操作的对象 |
获取表名
file_list = FileInfoList(where="文件夹的绝对路径")
# FileInfoList.CREATE_LIST 创建表单S表名
# FileInfoList.INSERT_LIST 插入表单数据的表名
# FileInfoList.ALL_LIST 所有创建表单和插入表单数据的表名的交集
file_list.table(mode=FileInfoList.CREATE_LIST)
根据表名获取 文件信息
file_list = FileInfoList(where="文件夹的绝对路径")
# FileInfoList.CREATE_LIST 创建表单的SQL
# FileInfoList.INSERT_LIST 插入表单数据的SQL
# FileInfoList.ALL_LIST 所有创建表单和插入表单数据的所有SQL
# 返回的是一个列表
sqls = file_list.find("eclinical_crf_item", mode=FileInfoList.ALL_LIST)
获取 文件信息
详细例子可查看 tests//file_info_example
file_list = FileInfoList(where="文件夹的绝对路径")
# FileInfoList.CREATE_LIST 创建表单的SQL
# FileInfoList.INSERT_LIST 插入表单数据的SQL
# FileInfoList.ALL_LIST 所有创建表单和插入表单数据的所有SQL
# 返回的是一个列表
sqls = file_list.lists(mode=FileInfoList.INSERT_LIST)
过滤生成
针对大的 Dump 文件,只能支持 过滤 Table 名
详细例子可查看 tests//big_dump_example
# absolute_file_path 读取文件的绝对路径
# absolute_out_put_folder 输出的文件夹的绝对路径
# reader 指定为
# 返回的 任务ID
tid = SliceFactory.slice(absolute_file_path=file,
absolute_out_put_folder=Path("Result"),
reader=DumpReader(tables=["eclinical_study_site"]))
通用过滤
详细列子可查看 tests//custom_filter_exclude_example,custom_filter_include_example,table_filter_example
# absolute_file_path 读取文件的绝对路径
# absolute_out_put_folder 输出的文件夹的绝对路径
# before_condition 在解析 sql 行前过滤
# after_condition 在解析 Sql 行后,生成文件前过滤
# PS,指定after_condition 会比较慢, 但是过滤功能最强
tid = SliceFactory.slice(
absolute_file_path=file, absolute_out_put_folder=Path("Result"),
before_condition=DumpTableByteCondition(tables=["eclinical_crf_codelist_item"]),
after_condition=DumpTableCondition(tables=["eclinical_crf_codelist_item"]))
flowchart LR
A[before condition 根据文本过滤] --> b[解析 SQL 语句] --> C[after condition 根据属性过滤]
Release 1.0.1
- 修改了生成的文件ID和记录的文件ID 不一致的BUG
- 在文件信息中,增加了文件大小信息,单位为字节
Release 1.0.2
- SliceFactory is_valid_folder_name 修改了正则表达式
Release 1.0.3
- 修改了writer结束线程的条件
Release 1.0.4
- 添加了序号
- 过滤了注释文件
- 修改了若干BUG
Release 1.0.5
- 增加了支持拆分:存储过程,Alter,Update,Delete,Call,TRUNCATE
- 删除了创建语句中自动生成的Drop
- 增加了遗漏为处理的日志
- 快速在大文件中拆分指定表
Release 1.0.6
- 增加了/*!mysqlversion ... */ 的支持
Release 1.0.7
- 临时增加了对 Linux的路径支持
Metadata
Release files for slicing 1.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| slicing-1.0.7.tar.gz | 19.2 kB | Without provenance | Details for slicing-1.0.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| slicing-1.0.7-py3-none-any.whl | Python 3 | none | any | Details for slicing-1.0.7-py3-none-any.whl |
Total release size: 53.7 kB
Release files / slicing-1.0.7.tar.gz
| Download URL | slicing-1.0.7.tar.gz |
|---|---|
| Size | 19.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ca9124cc766f1fe2e0ce0a0402458afab8bb14780a1ae745a835b7807b9e7a1a
|
|
BLAKE2b-256 checksum How to use checksums |
15d3e19c346f6305fc58fa5ad834821dd6572e148563a1d06782ca68c4cdaf26
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Release files / slicing-1.0.7-py3-none-any.whl
| Download URL | slicing-1.0.7-py3-none-any.whl |
|---|---|
| Size | 34.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b92202738335a2f57160caa2541710b63a45edca1f25e92fc9fb1c976427cd28
|
|
BLAKE2b-256 checksum How to use checksums |
285d4caf7880b9878b9098607831c85ce0bcbde5613434daf9fc09d93a5788ff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Security for slicing 1.0.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.