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.9.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

liquisource-1.1.9-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: liquisource-1.1.9.tar.gz
  • Upload date:
  • Size: 3.2 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.9.tar.gz
Algorithm Hash digest
SHA256 b286828aedd83286e2bc953872c631087fa6bdacfd4bf4654939e93114656433
MD5 8498c53a2521f176b87ccb6d68883bec
BLAKE2b-256 f53d240a786b9892eed87bf6017503bef21973455a63cf412927f26d6bd8cee7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: liquisource-1.1.9-py3-none-any.whl
  • Upload date:
  • Size: 4.7 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.9-py3-none-any.whl
Algorithm Hash digest
SHA256 3e7a2fd217d3ee74c3ba822fa257a6cf1e77847bbcd5104652ecd366ed7572b3
MD5 2e1360db295e3016846006954a87d289
BLAKE2b-256 b3353dce06a9210f51027acece56413599fe3a64f3936a477a350716f9f04d67

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