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.2.tar.gz
(2.0 kB
view details)
Built Distribution
File details
Details for the file liquisource-1.1.2.tar.gz
.
File metadata
- Download URL: liquisource-1.1.2.tar.gz
- Upload date:
- Size: 2.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aed81777497febde52df5062e8a7b6aa20065b5948dc00ded91abba934792d51 |
|
MD5 | 6c3adb69ccfb5ab6b58123fddf76d841 |
|
BLAKE2b-256 | ce11b653d5c1c7798b8135ceeb12bf0e11a0c107800d64495051269b76972047 |
File details
Details for the file liquisource-1.1.2-py3-none-any.whl
.
File metadata
- Download URL: liquisource-1.1.2-py3-none-any.whl
- Upload date:
- Size: 3.2 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 | 1238a5426d9c79349d172d2919e6a1cbd0b788260d88e0111cabed8d8add0c8a |
|
MD5 | 69d20d549c07526807f6101c9a236afe |
|
BLAKE2b-256 | c2d3d153a3dcd390fb412964b6631a221f9cc4b02606a8aa4c51aa3e95ff007b |