Custom insert for script in vertica/ch
Project description
Библиотека для вставки в таблицы, используя промежуточную
Типы СУБД для вставки:
- clickhouse
- vertica
Аргументы :
- script - код для вставки, тип: string
- sql_credentials - sql-креды для вставки, тип: json
- insert_table - имя таблицы, в которую идет вставка, тип: string
- add_args - аргументы для замены переменных в скрипте, тип: json
Usage
pip3 install swap-inserter-talenttech-oss
SQL CREDENTIALS:
sql_credentials = {
"vertica": {
"database": <VERTICA_DATABASE>,
"schema": <VERTICA_SCHEMA>,
"staging_schema": <VERTICA_STAGING_SCHEMA>,
"user": <VERTICA_WRITE_USER>,
"host": <VERTICA_HOST>,
"port": <VERTICA_PORT>,
"password": <VERTICA_WRITE_PASSWORD>,
"vertica_configs": {"host": <VERTICA_HOST>,
"port": <VERTICA_PORT>,
"backup_server_node": [<SERVER_NODE_1>, <SERVER_NODE_2>, <SERVER_NODE_3>},
},
"ch": {
"database": <CH_DATABASE>,
"user": <CH_WRITE_USER>,
"host": <CH_HOST_A>,
"port": <CH_PORT_TCP>,
"password": <CH_WRITE_PASSWORD>,
"alt_hosts": "{},{}:{}".format(
<CH_HOST_B>,
<CH_HOST_C>,
<CH_PORT_TCP>,
),
},
}
ПРИМЕР ИСПОЛЬЗОВАНИЯ VERTICA:
from inserter.vertica_swap_inserter import VerticaSwapInserter
script = "SELECT <FIELDS> FROM {schema}.{from_table}"
inserter = VerticaSwapInserter(
script=script,
sql_credentials=sql_credentials["vertica"],
insert_table=<TABLE_INSERT>,
add_args={
"schema": sql_credentials["vertica"]["schema"],
"from_table": <FROM_TABLE>
}
)
inserter.run()
ПРИМЕР ИСПОЛЬЗОВАНИЯ CH:
from inserter.ch_swap_inserter import CHSwapInserter
script = "SELECT <FIELDS> FROM {schema}.{from_table}"
inserter = CHSwapInserter(
script=script,
sql_credentials=sql_credentials["ch"],
insert_table=<TABLE_INSERT>,
add_args={
"database": sql_credential["ch"]["database"],
"from_table": <FROM_TABLE>
},
)
inserter.run()
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for swap-inserter-talenttech-oss-0.0.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d5163b5e77123df7ece863338529ad4e3c155cf4a147cd578ad879601b88d88 |
|
MD5 | 29e064bbbb938432007c50ac2ffb3297 |
|
BLAKE2b-256 | 7114b75e68f3661a44843c70e6cc8b447a887fcc2552fa007282144ef6b99c2c |
Close
Hashes for swap_inserter_talenttech_oss-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e65a95c38294cba0d8074e34015182168c9e8fab044652742a32cfa13682876c |
|
MD5 | 9cf8e1c8497c174e2a6556dbe271f5f9 |
|
BLAKE2b-256 | bfd681f290733804bfc677d88cf029dfc913010d5900eddecb2a340ac0ed32ca |