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
Release history Release notifications | RSS feed
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.8.tar.gz
(2.2 kB
view details)
Built Distribution
File details
Details for the file liquisource-1.1.8.tar.gz
.
File metadata
- Download URL: liquisource-1.1.8.tar.gz
- Upload date:
- Size: 2.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5dd93ef1964c29ef4663d2be9d571bee03db1dfabfe586dc0ed7d9a944f41d36 |
|
MD5 | a33b0a76efa7907c53d7c42abe27bcc2 |
|
BLAKE2b-256 | 3d6d5a13cc89e8165bdc160f3ad5cb487cf4f8db6037f18cda5d3e0b96183e40 |
File details
Details for the file liquisource-1.1.8-py3-none-any.whl
.
File metadata
- Download URL: liquisource-1.1.8-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb5da4a6445e58ccbf8f63d8bd525c3ab7d66be677f8ea2effcf1c9003998ef2 |
|
MD5 | 437adf21b810ea2c425c1e82837414ec |
|
BLAKE2b-256 | 14d5e8de361f3aeaba3e9549ff59116a37d75c3b16f31f4a3a4ab3b2c1f6cba9 |