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

Uploaded Source

Built Distribution

liquisource-1.2.1-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for liquisource-1.2.1.tar.gz
Algorithm Hash digest
SHA256 90dc085517f2367e8f8879bd6f5fc2114a77e848796f8a77095f95c044ee8d1b
MD5 870530e228b632c6a70c270b725429cd
BLAKE2b-256 59a7992cfdcd6bc115fa41810183996a17d9d3bb1d7bb9f6381a40d42279e858

See more details on using hashes here.

File details

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

File metadata

  • Download URL: liquisource-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 5.2 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.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 23c002b3bbbdaa5b5de105cd18c014b857d249dc8aacd4750bbb9d21c35ed105
MD5 406584c567a0da383a72de7a10f2cc68
BLAKE2b-256 a4e05a9bc3d319dd5f04afdcd639403194b09de0c5b10ed65d98d4b4459b124f

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