Skip to main content

A liquibase datasource client for python

Project description

liquibase数据源驱动

liquibase引入python3脚本,统一管理管理mongo、clickhouse的库表结构。changelog记录还是选在记录到mysql中,这样业务上会更加灵活

<changeSet id="xxxxx" author="xxxxxx" labels="mongo">
    <comment>xxxxx</comment>
    <executeCommand executable="python3">
        <arg value="script/db_tag/creat_collection.py"/>
    </executeCommand>
</changeSet>
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from liquibase_datasource import *


def create_tag_database():
    # 获取mongo链接实例
    client = get_client(filepath)


    return client[db]


def create_tag_collection():
    # 获取mongo链接实例
    db_name = get_tenant_shard(tag_database)
    client = get_client()
    db = client[db_name]

    # db开启分片
    client.admin.command("enableSharding", db_name)

    db.create_collection(tag_collection)

    # 创建索引
    coll = db[tag_collection]
    coll.create_index(
        [("id", 1), ("name", 1)])


if __name__ == "__main__":
    # 创建标签集合
    create_tag_database()
    create_tag_collection()

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

liquisource-1.1.3.tar.gz (2.1 kB view details)

Uploaded Source

Built Distribution

liquisource-1.1.3-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file liquisource-1.1.3.tar.gz.

File metadata

  • Download URL: liquisource-1.1.3.tar.gz
  • Upload date:
  • Size: 2.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.8

File hashes

Hashes for liquisource-1.1.3.tar.gz
Algorithm Hash digest
SHA256 56cea7910ba7c4e0aacda7067bdd9b2fb38f44a39bacb3cfa87512f1b80aae2b
MD5 8bc06456a046b640ece8532eec77af98
BLAKE2b-256 67600b07c66dc69b1a6f4f63d3b3a45e7cffe9a482e912b5294b592436c99f1d

See more details on using hashes here.

File details

Details for the file liquisource-1.1.3-py3-none-any.whl.

File metadata

  • Download URL: liquisource-1.1.3-py3-none-any.whl
  • Upload date:
  • Size: 3.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.8

File hashes

Hashes for liquisource-1.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ef56ef62509165d17f393421e61b765263f454443258cf62e8dd5eb696e95fc8
MD5 4d655c01af23d778208fbd0d654ba9e4
BLAKE2b-256 2b59795482ed1fe98061bd820363c2f68b6d4a6e53fb962fe13130d7b9769558

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