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.1.tar.gz
(2.0 kB
view details)
Built Distribution
File details
Details for the file liquisource-1.1.1.tar.gz
.
File metadata
- Download URL: liquisource-1.1.1.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 | fd1bb238f261fbff02aa645d4d79014f697331dd6e4f69261217f8ff64006a95 |
|
MD5 | b14f507e677102019141751875dd250b |
|
BLAKE2b-256 | 4be17fc6b078df5d9a6cb1adafbf92535e2f0428789e4f14974fe599ec7856d9 |
File details
Details for the file liquisource-1.1.1-py3-none-any.whl
.
File metadata
- Download URL: liquisource-1.1.1-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 | f7ab5a2e72bdd4cce8c4ae303dd4379e1a681092dc5ef52209640124900c8c03 |
|
MD5 | a171b6f45aa521bd0222dec51f7caec8 |
|
BLAKE2b-256 | 6eb8b0335e7581a7b39ce44eecc0a9dfb2c8b6f0c5e4d75026badfde7463af79 |