Skip to main content

Библиотека для вставки в таблицы, используя промежуточную

Типы СУБД для вставки:

  • clickhouse
  • vertica

Аргументы :

  1. script - код для вставки, тип: string
  2. sql_credentials - sql-креды для вставки, тип: json
  3. insert_table - имя таблицы, в которую идет вставка, тип: string
  4. 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()

Metadata

Release files for swap-inserter-talenttech-oss 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for swap-inserter-talenttech-oss 0.0.4
File Size Uploaded
swap-inserter-talenttech-oss-0.0.4.tar.gz 4.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for swap-inserter-talenttech-oss 0.0.4
File Interpreter ABI Platform
swap_inserter_talenttech_oss-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 10.3 kB

Release files / swap-inserter-talenttech-oss-0.0.4.tar.gz

Download URL swap-inserter-talenttech-oss-0.0.4.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
4d5163b5e77123df7ece863338529ad4e3c155cf4a147cd578ad879601b88d88
BLAKE2b-256 checksum
How to use checksums
7114b75e68f3661a44843c70e6cc8b447a887fcc2552fa007282144ef6b99c2c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.6.15

Release files / swap_inserter_talenttech_oss-0.0.4-py3-none-any.whl

Download URL swap_inserter_talenttech_oss-0.0.4-py3-none-any.whl
Size 5.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e65a95c38294cba0d8074e34015182168c9e8fab044652742a32cfa13682876c
BLAKE2b-256 checksum
How to use checksums
bfd681f290733804bfc677d88cf029dfc913010d5900eddecb2a340ac0ed32ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.6.15

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page