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.6.tar.gz
(2.3 kB
view details)
Built Distribution
File details
Details for the file liquisource-1.1.6.tar.gz
.
File metadata
- Download URL: liquisource-1.1.6.tar.gz
- Upload date:
- Size: 2.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4acf6164150292a75367250b2955d6e1a162e2a9e26ded6d3d64474ebe850139 |
|
MD5 | a579b39772aaa6ff1686d282e80d71c8 |
|
BLAKE2b-256 | dae7933c24d398466057f961ad8b09ff0bf736aa20b9df4844193c8662e33107 |
File details
Details for the file liquisource-1.1.6-py3-none-any.whl
.
File metadata
- Download URL: liquisource-1.1.6-py3-none-any.whl
- Upload date:
- Size: 3.5 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 | f34f4f2c284b99a4b2b6516361a0463fda9fb42b9ac8ec0ff6f08a0bb5f01be8 |
|
MD5 | 3cc597a134681746a518ea15d70b5226 |
|
BLAKE2b-256 | d3ee89889f7f6b7a698cc77f31a9dd9c3d36a898469069586c9abf08dfa7783f |