Skip to main content

Custom insert for script in vertica/ch

Project description

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

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

  • 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()

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

swap-inserter-talenttech-oss-0.0.4.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file swap-inserter-talenttech-oss-0.0.4.tar.gz.

File metadata

  • Download URL: swap-inserter-talenttech-oss-0.0.4.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for swap-inserter-talenttech-oss-0.0.4.tar.gz
Algorithm Hash digest
SHA256 4d5163b5e77123df7ece863338529ad4e3c155cf4a147cd578ad879601b88d88
MD5 29e064bbbb938432007c50ac2ffb3297
BLAKE2b-256 7114b75e68f3661a44843c70e6cc8b447a887fcc2552fa007282144ef6b99c2c

See more details on using hashes here.

File details

Details for the file swap_inserter_talenttech_oss-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: swap_inserter_talenttech_oss-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for swap_inserter_talenttech_oss-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e65a95c38294cba0d8074e34015182168c9e8fab044652742a32cfa13682876c
MD5 9cf8e1c8497c174e2a6556dbe271f5f9
BLAKE2b-256 bfd681f290733804bfc677d88cf029dfc913010d5900eddecb2a340ac0ed32ca

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page