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.4.tar.gz
(2.2 kB
view details)
Built Distribution
File details
Details for the file liquisource-1.1.4.tar.gz
.
File metadata
- Download URL: liquisource-1.1.4.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 | 5bb1392c2cc4a0858c27a288952c31550173d1d4137b4a7a902a3e049d19e283 |
|
MD5 | 0f49394525da8f6b049ad64a3e9653d8 |
|
BLAKE2b-256 | 76852e9c54ea14e1e0e0a2648957a7eb201eb8124ddb2dc941b79edac02824ca |
File details
Details for the file liquisource-1.1.4-py3-none-any.whl
.
File metadata
- Download URL: liquisource-1.1.4-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 | 645dab6719310a0b5e04f7c116f3e4c70954ada503cac63540d7681ddabe5973 |
|
MD5 | c8950cdc0c463e6ccfba250f24e77367 |
|
BLAKE2b-256 | be4c3042ffff1d66adede449aedaf18184df64e75ef0fe60fa82457e6fa664f9 |