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.5.tar.gz
(2.2 kB
view details)
Built Distribution
File details
Details for the file liquisource-1.1.5.tar.gz
.
File metadata
- Download URL: liquisource-1.1.5.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 | ea8380a735348b091dd7d5cc862ce3e1e4ff9d3bade217d007167a56c3689871 |
|
MD5 | a7575fc4ae1ca4c84eef339293a5925a |
|
BLAKE2b-256 | a3492c1719b734433ae39019731e6d7857fda07de8d07b2aeaa2ce081180ea7f |
File details
Details for the file liquisource-1.1.5-py3-none-any.whl
.
File metadata
- Download URL: liquisource-1.1.5-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 | ee0de4b170e04c2524413800998c1348b9eabd527f0fdcfa978c40d8a30b84d1 |
|
MD5 | cca26e0ec8033e37233a0f1287f14309 |
|
BLAKE2b-256 | d3cd2a5d9be1c66f510c35d67a000fdade715ad96a7f5305c147322df2494088 |