tk-db-utils


Nametk-db-utils JSON
Version 0.1.6 PyPI version JSON
download
home_pageNone
Summary一个基于 SQLAlchemy 2.0 的高可复用数据库工具库,提供完整的 CRUD 操作、批量数据处理和高级数据库功能。
upload_time2025-08-02 04:31:29
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseApache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
keywords crud database mysql orm postgresql sqlalchemy sqlite
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # tk-db-utils

一个基于 SQLAlchemy 2.0 的高可复用数据库工具库,提供完整的 CRUD 操作、批量数据处理和高级数据库功能。

## 特性

### 🚀 核心功能
- **SQLAlchemy 2.0 风格**: 完全采用 SQLAlchemy 2.0 的现代化 API
- **高可复用性**: 模块化设计,易于集成到任何项目中
- **完整的 CRUD 操作**: 支持增删改查的所有基本操作
- **批量数据处理**: 支持大批量数据的高效处理
- **多数据库支持**: 支持 MySQL、PostgreSQL、SQLite 等主流数据库

### 📊 高级数据库功能
- **INSERT IGNORE**: 支持忽略重复数据的批量插入
- **REPLACE INTO**: 支持数据替换的批量操作
- **分块处理**: 可配置批量大小,避免内存溢出
- **事务管理**: 自动事务处理,确保数据一致性
- **连接池管理**: 高效的数据库连接池管理
- **模式验证**: 自动检查 ORM 模型与数据库表结构的一致性
- **冲突检测**: 智能检测和处理唯一约束冲突

### 🛠️ 开发友好
- **类型提示**: 完整的 TypeScript 风格类型提示
- **错误处理**: 详细的错误信息和异常处理
- **日志系统**: 可配置的日志记录系统
- **向后兼容**: 保持与旧版本的兼容性

## 安装

```bash
pip install tk-db-utils
```

## 快速开始

### 1. 安装

```bash
pip install tk-db-utils
```

### 2. 配置数据库连接

本项目采用分离式配置管理,将敏感信息和引擎参数分别存储:

#### 敏感信息配置 (`.env`)
创建 `.env` 文件并配置数据库连接的敏感信息:

```env
# 数据库敏感信息配置
DB_HOST=localhost
DB_PORT=3306
DB_USERNAME=your_username
DB_PASSWORD=your_password
```

#### 引擎参数配置 (`db_config.toml`)
创建 `db_config.toml` 文件并配置数据库引擎参数:

```toml
[database]
database = "your_database_name"
driver = "pymysql"
dialect = "mysql"
charset = "utf8mb4"
collation = "utf8mb4_general_ci"

[engine]
echo = false
pool_size = 5
max_overflow = 10
pool_timeout = 30
pool_recycle = 3600
pool_pre_ping = true
```

> 💡 **提示**: 可以复制 `.env.example` 和 `db_config.example.toml` 文件作为模板开始配置。
> 
> 📖 **详细配置指南**: 查看 [CONFIG_GUIDE.md](CONFIG_GUIDE.md) 了解完整的配置说明。

### 3. 基础配置

```python
from tk_db_utils import (
    configure_database,
    init_db,
    set_logger_level,
    SqlAlChemyBase,
    DbOrmBaseMixedIn,
    BaseCurd
)
from sqlalchemy import Column, Integer, String, DateTime
from datetime import datetime

# 配置日志级别
set_logger_level('INFO')

# 配置数据库连接
configure_database(
    host="localhost",
    port=3306,
    username="your_username",
    password="your_password",
    database="your_database",
    driver="mysql",
    dialect="mysql+pymysql",
    # 引擎参数
    echo=True,
    pool_size=5,
    max_overflow=10
)

# 初始化数据库
init_db()
```

### 2. 定义数据模型

```python
class User(SqlAlChemyBase, DbOrmBaseMixedIn):
    """用户表模型"""
    __tablename__ = 'users'
    
    id = Column(Integer, primary_key=True, autoincrement=True)
    username = Column(String(50), unique=True, nullable=False)
    email = Column(String(100), unique=True, nullable=False)
    created_at = Column(DateTime, default=datetime.now)
```

### 3. 基础 CRUD 操作

```python
# 创建 CRUD 实例
crud = BaseCurd()

# 插入单条记录
user_data = {"username": "john", "email": "john@example.com"}
user_id = crud.insert_one(User, user_data)

# 批量插入
users_data = [
    {"username": "alice", "email": "alice@example.com"},
    {"username": "bob", "email": "bob@example.com"},
]
inserted_count = crud.bulk_insert(User, users_data, chunk_size=1000)

# 查询所有记录
all_users = crud.select_all(User, limit=10, offset=0)

# 根据ID查询
user = crud.select_by_id(User, 1)

# 根据条件查询
users = crud.select_by_conditions(User, {"username": "alice"})

# 更新记录
updated_count = crud.update_by_id(User, 1, {"email": "new@example.com"})

# 删除记录
deleted_count = crud.delete_by_id(User, 1)

# 统计记录数
total_count = crud.count(User)
```

## 高级功能

### 模式验证功能

```python
from tk_db_utils import (
    SchemaValidator,
    validate_schema_consistency,
    SchemaValidationError
)

# 方法1: 使用便捷函数进行验证
with get_session() as session:
    try:
        is_valid = validate_schema_consistency(
            model=User,
            engine=get_engine(),
            session=session,
            strict_mode=False,  # 非严格模式
            halt_on_error=True  # 发现错误时暂停等待用户确认
        )
        
        if is_valid:
            print("✅ 模式验证通过")
        else:
            print("❌ 模式验证失败")
            
    except SchemaValidationError as e:
        print(f"模式验证错误: {e}")

# 方法2: 使用 SchemaValidator 类进行详细验证
with get_session() as session:
    validator = SchemaValidator(get_engine(), session)
    
    result = validator.validate_model_schema(
        model=User,
        strict_mode=False
    )
    
    if not result['valid']:
        print("发现的问题:")
        for error in result['errors']:
            print(f"  - {error}")
```

### INSERT IGNORE 批量操作

```python
# 批量插入,忽略重复数据
duplicate_users = [
    {"username": "alice", "email": "alice@example.com"},  # 可能重复
    {"username": "david", "email": "david@example.com"},  # 新数据
]

# 使用 INSERT IGNORE,重复数据会被忽略
inserted_count = crud.bulk_insert_ignore(User, duplicate_users, chunk_size=1000)
print(f"实际插入了 {inserted_count} 条记录")
```

### REPLACE INTO 批量操作

```python
# 批量替换数据
replace_users = [
    {"id": 1, "username": "john_updated", "email": "john.new@example.com"},
    {"id": 100, "username": "new_user", "email": "new@example.com"},  # 新记录
]

# 使用 REPLACE INTO,存在则更新,不存在则插入
processed_count = crud.bulk_replace_into(User, replace_users, chunk_size=1000)
print(f"处理了 {processed_count} 条记录")
```

### 会话管理

```python
from tk_db_utils import get_session

# 使用上下文管理器
with get_session() as session:
    # 在会话中进行复杂查询
    users = session.query(User).filter(User.username.like('%admin%')).all()
    
    # 创建新记录
    new_user = User(username="admin", email="admin@example.com")
    session.add(new_user)
    # 会话结束时自动提交
```

### 原生 SQL 执行

```python
# 执行原生 SQL
result = crud.execute_raw_sql(
    "SELECT COUNT(*) as total FROM users WHERE created_at > :date",
    params={"date": "2024-01-01"}
)
```

## 数据库支持

### MySQL
```python
configure_database(
    host="localhost",
    port=3306,
    username="root",
    password="password",
    database="mydb",
    driver="mysql",
    dialect="mysql+pymysql"
)
```

### PostgreSQL
```python
configure_database(
    host="localhost",
    port=5432,
    username="postgres",
    password="password",
    database="mydb",
    driver="postgresql",
    dialect="postgresql+psycopg2"
)
```

### SQLite
```python
configure_database(
    host="",
    port=0,
    username="",
    password="",
    database="mydb.db",
    driver="sqlite",
    dialect="sqlite"
)
```

## 环境变量配置

你也可以通过环境变量来配置数据库连接:

```bash
# 数据库连接配置
export DB_HOST=localhost
export DB_PORT=3306
export DB_USERNAME=root
export DB_PASSWORD=password
export DB_DATABASE=mydb
export DB_DRIVER=mysql
export DB_DIALECT=mysql+pymysql

# 引擎参数配置
export DB_ECHO=true
export DB_POOL_SIZE=5
export DB_MAX_OVERFLOW=10
export DB_POOL_TIMEOUT=30
export DB_POOL_RECYCLE=3600
```

## 日志配置

```python
from tk_db_tool import set_logger_level, set_message_handler, set_message_config
import logging

# 设置日志级别
set_logger_level('DEBUG')

# 设置自定义日志处理器
handler = logging.FileHandler('app.log')
set_message_handler(handler)

# 设置日志配置
logger = logging.getLogger('my_app')
set_message_config(logger)
```

## 性能优化

### 批量操作建议

```python
# 对于大量数据,建议使用适当的批量大小
# 一般建议 1000-5000 条记录为一批

# 小数据量
crud.bulk_insert(User, small_data, chunk_size=1000)

# 大数据量
crud.bulk_insert(User, large_data, chunk_size=3000)

# 超大数据量
crud.bulk_insert(User, huge_data, chunk_size=5000)
```

### 连接池配置

```python
configure_database(
    # ... 其他配置
    pool_size=10,        # 连接池大小
    max_overflow=20,     # 最大溢出连接数
    pool_timeout=30,     # 获取连接超时时间
    pool_recycle=3600,   # 连接回收时间
)
```

## 错误处理

```python
try:
    crud.bulk_insert(User, invalid_data)
except ValueError as e:
    print(f"数据验证错误: {e}")
except RuntimeError as e:
    print(f"数据库操作错误: {e}")
except Exception as e:
    print(f"未知错误: {e}")
```

## 迁移指南

### 从旧版本迁移

如果你正在使用旧版本的 `bulk_insert_ignore_in_chunks` 方法:

```python
# 旧方法(仍然支持,但会显示警告)
crud.bulk_insert_ignore_in_chunks(User, data, chunk_size=1000)

# 新方法(推荐)
crud.bulk_insert_ignore(User, data, chunk_size=1000)
```

## 完整示例

查看 `example.py` 文件获取完整的使用示例,包括:
- 数据库配置
- 模型定义
- CRUD 操作
- INSERT IGNORE 和 REPLACE INTO
- 会话管理
- 错误处理

## 依赖要求

- Python >= 3.11
- SQLAlchemy >= 2.0
- PyMySQL (用于 MySQL)
- psycopg2 (用于 PostgreSQL)
- python-dotenv (用于环境变量)
- pydantic (用于数据验证)

## 许可证

MIT License

## 贡献

欢迎提交 Issue 和 Pull Request!

## 更新日志

### v0.1.2
- ✨ 重构为 SQLAlchemy 2.0 风格
- ✨ 新增 INSERT IGNORE 和 REPLACE INTO 支持
- ✨ 新增完整的 CRUD 操作方法
- ✨ 新增灵活的数据库配置系统
- ✨ 修复 message 模块在 pip 安装后的使用问题
- ✨ 新增批量操作的分块处理
- ✨ 新增多数据库支持
- ✨ 新增完整的类型提示
- ✨ 新增详细的错误处理和日志记录

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "tk-db-utils",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "crud, database, mysql, orm, postgresql, sqlalchemy, sqlite",
    "author": null,
    "author_email": "tiankongzhise <tiankongzhise@163.com>",
    "download_url": "https://files.pythonhosted.org/packages/19/ef/fb5af39dfc09236862b078f4fbffa6a16c164b6c2e3f9de03a3b9897c934/tk_db_utils-0.1.6.tar.gz",
    "platform": null,
    "description": "# tk-db-utils\n\n\u4e00\u4e2a\u57fa\u4e8e SQLAlchemy 2.0 \u7684\u9ad8\u53ef\u590d\u7528\u6570\u636e\u5e93\u5de5\u5177\u5e93\uff0c\u63d0\u4f9b\u5b8c\u6574\u7684 CRUD \u64cd\u4f5c\u3001\u6279\u91cf\u6570\u636e\u5904\u7406\u548c\u9ad8\u7ea7\u6570\u636e\u5e93\u529f\u80fd\u3002\n\n## \u7279\u6027\n\n### \ud83d\ude80 \u6838\u5fc3\u529f\u80fd\n- **SQLAlchemy 2.0 \u98ce\u683c**: \u5b8c\u5168\u91c7\u7528 SQLAlchemy 2.0 \u7684\u73b0\u4ee3\u5316 API\n- **\u9ad8\u53ef\u590d\u7528\u6027**: \u6a21\u5757\u5316\u8bbe\u8ba1\uff0c\u6613\u4e8e\u96c6\u6210\u5230\u4efb\u4f55\u9879\u76ee\u4e2d\n- **\u5b8c\u6574\u7684 CRUD \u64cd\u4f5c**: \u652f\u6301\u589e\u5220\u6539\u67e5\u7684\u6240\u6709\u57fa\u672c\u64cd\u4f5c\n- **\u6279\u91cf\u6570\u636e\u5904\u7406**: \u652f\u6301\u5927\u6279\u91cf\u6570\u636e\u7684\u9ad8\u6548\u5904\u7406\n- **\u591a\u6570\u636e\u5e93\u652f\u6301**: \u652f\u6301 MySQL\u3001PostgreSQL\u3001SQLite \u7b49\u4e3b\u6d41\u6570\u636e\u5e93\n\n### \ud83d\udcca \u9ad8\u7ea7\u6570\u636e\u5e93\u529f\u80fd\n- **INSERT IGNORE**: \u652f\u6301\u5ffd\u7565\u91cd\u590d\u6570\u636e\u7684\u6279\u91cf\u63d2\u5165\n- **REPLACE INTO**: \u652f\u6301\u6570\u636e\u66ff\u6362\u7684\u6279\u91cf\u64cd\u4f5c\n- **\u5206\u5757\u5904\u7406**: \u53ef\u914d\u7f6e\u6279\u91cf\u5927\u5c0f\uff0c\u907f\u514d\u5185\u5b58\u6ea2\u51fa\n- **\u4e8b\u52a1\u7ba1\u7406**: \u81ea\u52a8\u4e8b\u52a1\u5904\u7406\uff0c\u786e\u4fdd\u6570\u636e\u4e00\u81f4\u6027\n- **\u8fde\u63a5\u6c60\u7ba1\u7406**: \u9ad8\u6548\u7684\u6570\u636e\u5e93\u8fde\u63a5\u6c60\u7ba1\u7406\n- **\u6a21\u5f0f\u9a8c\u8bc1**: \u81ea\u52a8\u68c0\u67e5 ORM \u6a21\u578b\u4e0e\u6570\u636e\u5e93\u8868\u7ed3\u6784\u7684\u4e00\u81f4\u6027\n- **\u51b2\u7a81\u68c0\u6d4b**: \u667a\u80fd\u68c0\u6d4b\u548c\u5904\u7406\u552f\u4e00\u7ea6\u675f\u51b2\u7a81\n\n### \ud83d\udee0\ufe0f \u5f00\u53d1\u53cb\u597d\n- **\u7c7b\u578b\u63d0\u793a**: \u5b8c\u6574\u7684 TypeScript \u98ce\u683c\u7c7b\u578b\u63d0\u793a\n- **\u9519\u8bef\u5904\u7406**: \u8be6\u7ec6\u7684\u9519\u8bef\u4fe1\u606f\u548c\u5f02\u5e38\u5904\u7406\n- **\u65e5\u5fd7\u7cfb\u7edf**: \u53ef\u914d\u7f6e\u7684\u65e5\u5fd7\u8bb0\u5f55\u7cfb\u7edf\n- **\u5411\u540e\u517c\u5bb9**: \u4fdd\u6301\u4e0e\u65e7\u7248\u672c\u7684\u517c\u5bb9\u6027\n\n## \u5b89\u88c5\n\n```bash\npip install tk-db-utils\n```\n\n## \u5feb\u901f\u5f00\u59cb\n\n### 1. \u5b89\u88c5\n\n```bash\npip install tk-db-utils\n```\n\n### 2. \u914d\u7f6e\u6570\u636e\u5e93\u8fde\u63a5\n\n\u672c\u9879\u76ee\u91c7\u7528\u5206\u79bb\u5f0f\u914d\u7f6e\u7ba1\u7406\uff0c\u5c06\u654f\u611f\u4fe1\u606f\u548c\u5f15\u64ce\u53c2\u6570\u5206\u522b\u5b58\u50a8\uff1a\n\n#### \u654f\u611f\u4fe1\u606f\u914d\u7f6e (`.env`)\n\u521b\u5efa `.env` \u6587\u4ef6\u5e76\u914d\u7f6e\u6570\u636e\u5e93\u8fde\u63a5\u7684\u654f\u611f\u4fe1\u606f\uff1a\n\n```env\n# \u6570\u636e\u5e93\u654f\u611f\u4fe1\u606f\u914d\u7f6e\nDB_HOST=localhost\nDB_PORT=3306\nDB_USERNAME=your_username\nDB_PASSWORD=your_password\n```\n\n#### \u5f15\u64ce\u53c2\u6570\u914d\u7f6e (`db_config.toml`)\n\u521b\u5efa `db_config.toml` \u6587\u4ef6\u5e76\u914d\u7f6e\u6570\u636e\u5e93\u5f15\u64ce\u53c2\u6570\uff1a\n\n```toml\n[database]\ndatabase = \"your_database_name\"\ndriver = \"pymysql\"\ndialect = \"mysql\"\ncharset = \"utf8mb4\"\ncollation = \"utf8mb4_general_ci\"\n\n[engine]\necho = false\npool_size = 5\nmax_overflow = 10\npool_timeout = 30\npool_recycle = 3600\npool_pre_ping = true\n```\n\n> \ud83d\udca1 **\u63d0\u793a**: \u53ef\u4ee5\u590d\u5236 `.env.example` \u548c `db_config.example.toml` \u6587\u4ef6\u4f5c\u4e3a\u6a21\u677f\u5f00\u59cb\u914d\u7f6e\u3002\n> \n> \ud83d\udcd6 **\u8be6\u7ec6\u914d\u7f6e\u6307\u5357**: \u67e5\u770b [CONFIG_GUIDE.md](CONFIG_GUIDE.md) \u4e86\u89e3\u5b8c\u6574\u7684\u914d\u7f6e\u8bf4\u660e\u3002\n\n### 3. \u57fa\u7840\u914d\u7f6e\n\n```python\nfrom tk_db_utils import (\n    configure_database,\n    init_db,\n    set_logger_level,\n    SqlAlChemyBase,\n    DbOrmBaseMixedIn,\n    BaseCurd\n)\nfrom sqlalchemy import Column, Integer, String, DateTime\nfrom datetime import datetime\n\n# \u914d\u7f6e\u65e5\u5fd7\u7ea7\u522b\nset_logger_level('INFO')\n\n# \u914d\u7f6e\u6570\u636e\u5e93\u8fde\u63a5\nconfigure_database(\n    host=\"localhost\",\n    port=3306,\n    username=\"your_username\",\n    password=\"your_password\",\n    database=\"your_database\",\n    driver=\"mysql\",\n    dialect=\"mysql+pymysql\",\n    # \u5f15\u64ce\u53c2\u6570\n    echo=True,\n    pool_size=5,\n    max_overflow=10\n)\n\n# \u521d\u59cb\u5316\u6570\u636e\u5e93\ninit_db()\n```\n\n### 2. \u5b9a\u4e49\u6570\u636e\u6a21\u578b\n\n```python\nclass User(SqlAlChemyBase, DbOrmBaseMixedIn):\n    \"\"\"\u7528\u6237\u8868\u6a21\u578b\"\"\"\n    __tablename__ = 'users'\n    \n    id = Column(Integer, primary_key=True, autoincrement=True)\n    username = Column(String(50), unique=True, nullable=False)\n    email = Column(String(100), unique=True, nullable=False)\n    created_at = Column(DateTime, default=datetime.now)\n```\n\n### 3. \u57fa\u7840 CRUD \u64cd\u4f5c\n\n```python\n# \u521b\u5efa CRUD \u5b9e\u4f8b\ncrud = BaseCurd()\n\n# \u63d2\u5165\u5355\u6761\u8bb0\u5f55\nuser_data = {\"username\": \"john\", \"email\": \"john@example.com\"}\nuser_id = crud.insert_one(User, user_data)\n\n# \u6279\u91cf\u63d2\u5165\nusers_data = [\n    {\"username\": \"alice\", \"email\": \"alice@example.com\"},\n    {\"username\": \"bob\", \"email\": \"bob@example.com\"},\n]\ninserted_count = crud.bulk_insert(User, users_data, chunk_size=1000)\n\n# \u67e5\u8be2\u6240\u6709\u8bb0\u5f55\nall_users = crud.select_all(User, limit=10, offset=0)\n\n# \u6839\u636eID\u67e5\u8be2\nuser = crud.select_by_id(User, 1)\n\n# \u6839\u636e\u6761\u4ef6\u67e5\u8be2\nusers = crud.select_by_conditions(User, {\"username\": \"alice\"})\n\n# \u66f4\u65b0\u8bb0\u5f55\nupdated_count = crud.update_by_id(User, 1, {\"email\": \"new@example.com\"})\n\n# \u5220\u9664\u8bb0\u5f55\ndeleted_count = crud.delete_by_id(User, 1)\n\n# \u7edf\u8ba1\u8bb0\u5f55\u6570\ntotal_count = crud.count(User)\n```\n\n## \u9ad8\u7ea7\u529f\u80fd\n\n### \u6a21\u5f0f\u9a8c\u8bc1\u529f\u80fd\n\n```python\nfrom tk_db_utils import (\n    SchemaValidator,\n    validate_schema_consistency,\n    SchemaValidationError\n)\n\n# \u65b9\u6cd51: \u4f7f\u7528\u4fbf\u6377\u51fd\u6570\u8fdb\u884c\u9a8c\u8bc1\nwith get_session() as session:\n    try:\n        is_valid = validate_schema_consistency(\n            model=User,\n            engine=get_engine(),\n            session=session,\n            strict_mode=False,  # \u975e\u4e25\u683c\u6a21\u5f0f\n            halt_on_error=True  # \u53d1\u73b0\u9519\u8bef\u65f6\u6682\u505c\u7b49\u5f85\u7528\u6237\u786e\u8ba4\n        )\n        \n        if is_valid:\n            print(\"\u2705 \u6a21\u5f0f\u9a8c\u8bc1\u901a\u8fc7\")\n        else:\n            print(\"\u274c \u6a21\u5f0f\u9a8c\u8bc1\u5931\u8d25\")\n            \n    except SchemaValidationError as e:\n        print(f\"\u6a21\u5f0f\u9a8c\u8bc1\u9519\u8bef: {e}\")\n\n# \u65b9\u6cd52: \u4f7f\u7528 SchemaValidator \u7c7b\u8fdb\u884c\u8be6\u7ec6\u9a8c\u8bc1\nwith get_session() as session:\n    validator = SchemaValidator(get_engine(), session)\n    \n    result = validator.validate_model_schema(\n        model=User,\n        strict_mode=False\n    )\n    \n    if not result['valid']:\n        print(\"\u53d1\u73b0\u7684\u95ee\u9898:\")\n        for error in result['errors']:\n            print(f\"  - {error}\")\n```\n\n### INSERT IGNORE \u6279\u91cf\u64cd\u4f5c\n\n```python\n# \u6279\u91cf\u63d2\u5165\uff0c\u5ffd\u7565\u91cd\u590d\u6570\u636e\nduplicate_users = [\n    {\"username\": \"alice\", \"email\": \"alice@example.com\"},  # \u53ef\u80fd\u91cd\u590d\n    {\"username\": \"david\", \"email\": \"david@example.com\"},  # \u65b0\u6570\u636e\n]\n\n# \u4f7f\u7528 INSERT IGNORE\uff0c\u91cd\u590d\u6570\u636e\u4f1a\u88ab\u5ffd\u7565\ninserted_count = crud.bulk_insert_ignore(User, duplicate_users, chunk_size=1000)\nprint(f\"\u5b9e\u9645\u63d2\u5165\u4e86 {inserted_count} \u6761\u8bb0\u5f55\")\n```\n\n### REPLACE INTO \u6279\u91cf\u64cd\u4f5c\n\n```python\n# \u6279\u91cf\u66ff\u6362\u6570\u636e\nreplace_users = [\n    {\"id\": 1, \"username\": \"john_updated\", \"email\": \"john.new@example.com\"},\n    {\"id\": 100, \"username\": \"new_user\", \"email\": \"new@example.com\"},  # \u65b0\u8bb0\u5f55\n]\n\n# \u4f7f\u7528 REPLACE INTO\uff0c\u5b58\u5728\u5219\u66f4\u65b0\uff0c\u4e0d\u5b58\u5728\u5219\u63d2\u5165\nprocessed_count = crud.bulk_replace_into(User, replace_users, chunk_size=1000)\nprint(f\"\u5904\u7406\u4e86 {processed_count} \u6761\u8bb0\u5f55\")\n```\n\n### \u4f1a\u8bdd\u7ba1\u7406\n\n```python\nfrom tk_db_utils import get_session\n\n# \u4f7f\u7528\u4e0a\u4e0b\u6587\u7ba1\u7406\u5668\nwith get_session() as session:\n    # \u5728\u4f1a\u8bdd\u4e2d\u8fdb\u884c\u590d\u6742\u67e5\u8be2\n    users = session.query(User).filter(User.username.like('%admin%')).all()\n    \n    # \u521b\u5efa\u65b0\u8bb0\u5f55\n    new_user = User(username=\"admin\", email=\"admin@example.com\")\n    session.add(new_user)\n    # \u4f1a\u8bdd\u7ed3\u675f\u65f6\u81ea\u52a8\u63d0\u4ea4\n```\n\n### \u539f\u751f SQL \u6267\u884c\n\n```python\n# \u6267\u884c\u539f\u751f SQL\nresult = crud.execute_raw_sql(\n    \"SELECT COUNT(*) as total FROM users WHERE created_at > :date\",\n    params={\"date\": \"2024-01-01\"}\n)\n```\n\n## \u6570\u636e\u5e93\u652f\u6301\n\n### MySQL\n```python\nconfigure_database(\n    host=\"localhost\",\n    port=3306,\n    username=\"root\",\n    password=\"password\",\n    database=\"mydb\",\n    driver=\"mysql\",\n    dialect=\"mysql+pymysql\"\n)\n```\n\n### PostgreSQL\n```python\nconfigure_database(\n    host=\"localhost\",\n    port=5432,\n    username=\"postgres\",\n    password=\"password\",\n    database=\"mydb\",\n    driver=\"postgresql\",\n    dialect=\"postgresql+psycopg2\"\n)\n```\n\n### SQLite\n```python\nconfigure_database(\n    host=\"\",\n    port=0,\n    username=\"\",\n    password=\"\",\n    database=\"mydb.db\",\n    driver=\"sqlite\",\n    dialect=\"sqlite\"\n)\n```\n\n## \u73af\u5883\u53d8\u91cf\u914d\u7f6e\n\n\u4f60\u4e5f\u53ef\u4ee5\u901a\u8fc7\u73af\u5883\u53d8\u91cf\u6765\u914d\u7f6e\u6570\u636e\u5e93\u8fde\u63a5\uff1a\n\n```bash\n# \u6570\u636e\u5e93\u8fde\u63a5\u914d\u7f6e\nexport DB_HOST=localhost\nexport DB_PORT=3306\nexport DB_USERNAME=root\nexport DB_PASSWORD=password\nexport DB_DATABASE=mydb\nexport DB_DRIVER=mysql\nexport DB_DIALECT=mysql+pymysql\n\n# \u5f15\u64ce\u53c2\u6570\u914d\u7f6e\nexport DB_ECHO=true\nexport DB_POOL_SIZE=5\nexport DB_MAX_OVERFLOW=10\nexport DB_POOL_TIMEOUT=30\nexport DB_POOL_RECYCLE=3600\n```\n\n## \u65e5\u5fd7\u914d\u7f6e\n\n```python\nfrom tk_db_tool import set_logger_level, set_message_handler, set_message_config\nimport logging\n\n# \u8bbe\u7f6e\u65e5\u5fd7\u7ea7\u522b\nset_logger_level('DEBUG')\n\n# \u8bbe\u7f6e\u81ea\u5b9a\u4e49\u65e5\u5fd7\u5904\u7406\u5668\nhandler = logging.FileHandler('app.log')\nset_message_handler(handler)\n\n# \u8bbe\u7f6e\u65e5\u5fd7\u914d\u7f6e\nlogger = logging.getLogger('my_app')\nset_message_config(logger)\n```\n\n## \u6027\u80fd\u4f18\u5316\n\n### \u6279\u91cf\u64cd\u4f5c\u5efa\u8bae\n\n```python\n# \u5bf9\u4e8e\u5927\u91cf\u6570\u636e\uff0c\u5efa\u8bae\u4f7f\u7528\u9002\u5f53\u7684\u6279\u91cf\u5927\u5c0f\n# \u4e00\u822c\u5efa\u8bae 1000-5000 \u6761\u8bb0\u5f55\u4e3a\u4e00\u6279\n\n# \u5c0f\u6570\u636e\u91cf\ncrud.bulk_insert(User, small_data, chunk_size=1000)\n\n# \u5927\u6570\u636e\u91cf\ncrud.bulk_insert(User, large_data, chunk_size=3000)\n\n# \u8d85\u5927\u6570\u636e\u91cf\ncrud.bulk_insert(User, huge_data, chunk_size=5000)\n```\n\n### \u8fde\u63a5\u6c60\u914d\u7f6e\n\n```python\nconfigure_database(\n    # ... \u5176\u4ed6\u914d\u7f6e\n    pool_size=10,        # \u8fde\u63a5\u6c60\u5927\u5c0f\n    max_overflow=20,     # \u6700\u5927\u6ea2\u51fa\u8fde\u63a5\u6570\n    pool_timeout=30,     # \u83b7\u53d6\u8fde\u63a5\u8d85\u65f6\u65f6\u95f4\n    pool_recycle=3600,   # \u8fde\u63a5\u56de\u6536\u65f6\u95f4\n)\n```\n\n## \u9519\u8bef\u5904\u7406\n\n```python\ntry:\n    crud.bulk_insert(User, invalid_data)\nexcept ValueError as e:\n    print(f\"\u6570\u636e\u9a8c\u8bc1\u9519\u8bef: {e}\")\nexcept RuntimeError as e:\n    print(f\"\u6570\u636e\u5e93\u64cd\u4f5c\u9519\u8bef: {e}\")\nexcept Exception as e:\n    print(f\"\u672a\u77e5\u9519\u8bef: {e}\")\n```\n\n## \u8fc1\u79fb\u6307\u5357\n\n### \u4ece\u65e7\u7248\u672c\u8fc1\u79fb\n\n\u5982\u679c\u4f60\u6b63\u5728\u4f7f\u7528\u65e7\u7248\u672c\u7684 `bulk_insert_ignore_in_chunks` \u65b9\u6cd5\uff1a\n\n```python\n# \u65e7\u65b9\u6cd5\uff08\u4ecd\u7136\u652f\u6301\uff0c\u4f46\u4f1a\u663e\u793a\u8b66\u544a\uff09\ncrud.bulk_insert_ignore_in_chunks(User, data, chunk_size=1000)\n\n# \u65b0\u65b9\u6cd5\uff08\u63a8\u8350\uff09\ncrud.bulk_insert_ignore(User, data, chunk_size=1000)\n```\n\n## \u5b8c\u6574\u793a\u4f8b\n\n\u67e5\u770b `example.py` \u6587\u4ef6\u83b7\u53d6\u5b8c\u6574\u7684\u4f7f\u7528\u793a\u4f8b\uff0c\u5305\u62ec\uff1a\n- \u6570\u636e\u5e93\u914d\u7f6e\n- \u6a21\u578b\u5b9a\u4e49\n- CRUD \u64cd\u4f5c\n- INSERT IGNORE \u548c REPLACE INTO\n- \u4f1a\u8bdd\u7ba1\u7406\n- \u9519\u8bef\u5904\u7406\n\n## \u4f9d\u8d56\u8981\u6c42\n\n- Python >= 3.11\n- SQLAlchemy >= 2.0\n- PyMySQL (\u7528\u4e8e MySQL)\n- psycopg2 (\u7528\u4e8e PostgreSQL)\n- python-dotenv (\u7528\u4e8e\u73af\u5883\u53d8\u91cf)\n- pydantic (\u7528\u4e8e\u6570\u636e\u9a8c\u8bc1)\n\n## \u8bb8\u53ef\u8bc1\n\nMIT License\n\n## \u8d21\u732e\n\n\u6b22\u8fce\u63d0\u4ea4 Issue \u548c Pull Request\uff01\n\n## \u66f4\u65b0\u65e5\u5fd7\n\n### v0.1.2\n- \u2728 \u91cd\u6784\u4e3a SQLAlchemy 2.0 \u98ce\u683c\n- \u2728 \u65b0\u589e INSERT IGNORE \u548c REPLACE INTO \u652f\u6301\n- \u2728 \u65b0\u589e\u5b8c\u6574\u7684 CRUD \u64cd\u4f5c\u65b9\u6cd5\n- \u2728 \u65b0\u589e\u7075\u6d3b\u7684\u6570\u636e\u5e93\u914d\u7f6e\u7cfb\u7edf\n- \u2728 \u4fee\u590d message \u6a21\u5757\u5728 pip \u5b89\u88c5\u540e\u7684\u4f7f\u7528\u95ee\u9898\n- \u2728 \u65b0\u589e\u6279\u91cf\u64cd\u4f5c\u7684\u5206\u5757\u5904\u7406\n- \u2728 \u65b0\u589e\u591a\u6570\u636e\u5e93\u652f\u6301\n- \u2728 \u65b0\u589e\u5b8c\u6574\u7684\u7c7b\u578b\u63d0\u793a\n- \u2728 \u65b0\u589e\u8be6\u7ec6\u7684\u9519\u8bef\u5904\u7406\u548c\u65e5\u5fd7\u8bb0\u5f55\n",
    "bugtrack_url": null,
    "license": "Apache License\n                                   Version 2.0, January 2004\n                                http://www.apache.org/licenses/\n        \n           TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n        \n           1. Definitions.\n        \n              \"License\" shall mean the terms and conditions for use, reproduction,\n              and distribution as defined by Sections 1 through 9 of this document.\n        \n              \"Licensor\" shall mean the copyright owner or entity authorized by\n              the copyright owner that is granting the License.\n        \n              \"Legal Entity\" shall mean the union of the acting entity and all\n              other entities that control, are controlled by, or are under common\n              control with that entity. For the purposes of this definition,\n              \"control\" means (i) the power, direct or indirect, to cause the\n              direction or management of such entity, whether by contract or\n              otherwise, or (ii) ownership of fifty percent (50%) or more of the\n              outstanding shares, or (iii) beneficial ownership of such entity.\n        \n              \"You\" (or \"Your\") shall mean an individual or Legal Entity\n              exercising permissions granted by this License.\n        \n              \"Source\" form shall mean the preferred form for making modifications,\n              including but not limited to software source code, documentation\n              source, and configuration files.\n        \n              \"Object\" form shall mean any form resulting from mechanical\n              transformation or translation of a Source form, including but\n              not limited to compiled object code, generated documentation,\n              and conversions to other media types.\n        \n              \"Work\" shall mean the work of authorship, whether in Source or\n              Object form, made available under the License, as indicated by a\n              copyright notice that is included in or attached to the work\n              (an example is provided in the Appendix below).\n        \n              \"Derivative Works\" shall mean any work, whether in Source or Object\n              form, that is based on (or derived from) the Work and for which the\n              editorial revisions, annotations, elaborations, or other modifications\n              represent, as a whole, an original work of authorship. For the purposes\n              of this License, Derivative Works shall not include works that remain\n              separable from, or merely link (or bind by name) to the interfaces of,\n              the Work and Derivative Works thereof.\n        \n              \"Contribution\" shall mean any work of authorship, including\n              the original version of the Work and any modifications or additions\n              to that Work or Derivative Works thereof, that is intentionally\n              submitted to Licensor for inclusion in the Work by the copyright owner\n              or by an individual or Legal Entity authorized to submit on behalf of\n              the copyright owner. For the purposes of this definition, \"submitted\"\n              means any form of electronic, verbal, or written communication sent\n              to the Licensor or its representatives, including but not limited to\n              communication on electronic mailing lists, source code control systems,\n              and issue tracking systems that are managed by, or on behalf of, the\n              Licensor for the purpose of discussing and improving the Work, but\n              excluding communication that is conspicuously marked or otherwise\n              designated in writing by the copyright owner as \"Not a Contribution.\"\n        \n              \"Contributor\" shall mean Licensor and any individual or Legal Entity\n              on behalf of whom a Contribution has been received by Licensor and\n              subsequently incorporated within the Work.\n        \n           2. Grant of Copyright License. Subject to the terms and conditions of\n              this License, each Contributor hereby grants to You a perpetual,\n              worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n              copyright license to reproduce, prepare Derivative Works of,\n              publicly display, publicly perform, sublicense, and distribute the\n              Work and such Derivative Works in Source or Object form.\n        \n           3. Grant of Patent License. Subject to the terms and conditions of\n              this License, each Contributor hereby grants to You a perpetual,\n              worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n              (except as stated in this section) patent license to make, have made,\n              use, offer to sell, sell, import, and otherwise transfer the Work,\n              where such license applies only to those patent claims licensable\n              by such Contributor that are necessarily infringed by their\n              Contribution(s) alone or by combination of their Contribution(s)\n              with the Work to which such Contribution(s) was submitted. If You\n              institute patent litigation against any entity (including a\n              cross-claim or counterclaim in a lawsuit) alleging that the Work\n              or a Contribution incorporated within the Work constitutes direct\n              or contributory patent infringement, then any patent licenses\n              granted to You under this License for that Work shall terminate\n              as of the date such litigation is filed.\n        \n           4. Redistribution. You may reproduce and distribute copies of the\n              Work or Derivative Works thereof in any medium, with or without\n              modifications, and in Source or Object form, provided that You\n              meet the following conditions:\n        \n              (a) You must give any other recipients of the Work or\n                  Derivative Works a copy of this License; and\n        \n              (b) You must cause any modified files to carry prominent notices\n                  stating that You changed the files; and\n        \n              (c) You must retain, in the Source form of any Derivative Works\n                  that You distribute, all copyright, patent, trademark, and\n                  attribution notices from the Source form of the Work,\n                  excluding those notices that do not pertain to any part of\n                  the Derivative Works; and\n        \n              (d) If the Work includes a \"NOTICE\" text file as part of its\n                  distribution, then any Derivative Works that You distribute must\n                  include a readable copy of the attribution notices contained\n                  within such NOTICE file, excluding those notices that do not\n                  pertain to any part of the Derivative Works, in at least one\n                  of the following places: within a NOTICE text file distributed\n                  as part of the Derivative Works; within the Source form or\n                  documentation, if provided along with the Derivative Works; or,\n                  within a display generated by the Derivative Works, if and\n                  wherever such third-party notices normally appear. The contents\n                  of the NOTICE file are for informational purposes only and\n                  do not modify the License. You may add Your own attribution\n                  notices within Derivative Works that You distribute, alongside\n                  or as an addendum to the NOTICE text from the Work, provided\n                  that such additional attribution notices cannot be construed\n                  as modifying the License.\n        \n              You may add Your own copyright statement to Your modifications and\n              may provide additional or different license terms and conditions\n              for use, reproduction, or distribution of Your modifications, or\n              for any such Derivative Works as a whole, provided Your use,\n              reproduction, and distribution of the Work otherwise complies with\n              the conditions stated in this License.\n        \n           5. Submission of Contributions. Unless You explicitly state otherwise,\n              any Contribution intentionally submitted for inclusion in the Work\n              by You to the Licensor shall be under the terms and conditions of\n              this License, without any additional terms or conditions.\n              Notwithstanding the above, nothing herein shall supersede or modify\n              the terms of any separate license agreement you may have executed\n              with Licensor regarding such Contributions.\n        \n           6. Trademarks. This License does not grant permission to use the trade\n              names, trademarks, service marks, or product names of the Licensor,\n              except as required for reasonable and customary use in describing the\n              origin of the Work and reproducing the content of the NOTICE file.\n        \n           7. Disclaimer of Warranty. Unless required by applicable law or\n              agreed to in writing, Licensor provides the Work (and each\n              Contributor provides its Contributions) on an \"AS IS\" BASIS,\n              WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n              implied, including, without limitation, any warranties or conditions\n              of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n              PARTICULAR PURPOSE. You are solely responsible for determining the\n              appropriateness of using or redistributing the Work and assume any\n              risks associated with Your exercise of permissions under this License.\n        \n           8. Limitation of Liability. In no event and under no legal theory,\n              whether in tort (including negligence), contract, or otherwise,\n              unless required by applicable law (such as deliberate and grossly\n              negligent acts) or agreed to in writing, shall any Contributor be\n              liable to You for damages, including any direct, indirect, special,\n              incidental, or consequential damages of any character arising as a\n              result of this License or out of the use or inability to use the\n              Work (including but not limited to damages for loss of goodwill,\n              work stoppage, computer failure or malfunction, or any and all\n              other commercial damages or losses), even if such Contributor\n              has been advised of the possibility of such damages.\n        \n           9. Accepting Warranty or Additional Liability. While redistributing\n              the Work or Derivative Works thereof, You may choose to offer,\n              and charge a fee for, acceptance of support, warranty, indemnity,\n              or other liability obligations and/or rights consistent with this\n              License. However, in accepting such obligations, You may act only\n              on Your own behalf and on Your sole responsibility, not on behalf\n              of any other Contributor, and only if You agree to indemnify,\n              defend, and hold each Contributor harmless for any liability\n              incurred by, or claims asserted against, such Contributor by reason\n              of your accepting any such warranty or additional liability.\n        \n           END OF TERMS AND CONDITIONS\n        \n           APPENDIX: How to apply the Apache License to your work.\n        \n              To apply the Apache License to your work, attach the following\n              boilerplate notice, with the fields enclosed by brackets \"[]\"\n              replaced with your own identifying information. (Don't include\n              the brackets!)  The text should be enclosed in the appropriate\n              comment syntax for the file format. We also recommend that a\n              file or class name and description of purpose be included on the\n              same \"printed page\" as the copyright notice for easier\n              identification within third-party archives.\n        \n           Copyright [yyyy] [name of copyright owner]\n        \n           Licensed under the Apache License, Version 2.0 (the \"License\");\n           you may not use this file except in compliance with the License.\n           You may obtain a copy of the License at\n        \n               http://www.apache.org/licenses/LICENSE-2.0\n        \n           Unless required by applicable law or agreed to in writing, software\n           distributed under the License is distributed on an \"AS IS\" BASIS,\n           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n           See the License for the specific language governing permissions and\n           limitations under the License.",
    "summary": "\u4e00\u4e2a\u57fa\u4e8e SQLAlchemy 2.0 \u7684\u9ad8\u53ef\u590d\u7528\u6570\u636e\u5e93\u5de5\u5177\u5e93\uff0c\u63d0\u4f9b\u5b8c\u6574\u7684 CRUD \u64cd\u4f5c\u3001\u6279\u91cf\u6570\u636e\u5904\u7406\u548c\u9ad8\u7ea7\u6570\u636e\u5e93\u529f\u80fd\u3002",
    "version": "0.1.6",
    "project_urls": {
        "Documentation": "https://github.com/tiankongzhise/tk-db-utils#readme",
        "Homepage": "https://github.com/tiankongzhise/tk-db-utils",
        "Issues": "https://github.com/tiankongzhise/tk-db-utils/issues",
        "Repository": "https://github.com/tiankongzhise/tk-db-utils"
    },
    "split_keywords": [
        "crud",
        " database",
        " mysql",
        " orm",
        " postgresql",
        " sqlalchemy",
        " sqlite"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "ae9416c39cd3e01c7f7778180330ed5355195e2d4874e8672a7041deccf0e526",
                "md5": "7e187cef6dea1ce8f1d53478df2cbcc0",
                "sha256": "1e55aed40d018b84ee71f80944dbdb4cbb3cb9dcc95db32430b6d7f19e8849b2"
            },
            "downloads": -1,
            "filename": "tk_db_utils-0.1.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7e187cef6dea1ce8f1d53478df2cbcc0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 36216,
            "upload_time": "2025-08-02T04:31:28",
            "upload_time_iso_8601": "2025-08-02T04:31:28.128001Z",
            "url": "https://files.pythonhosted.org/packages/ae/94/16c39cd3e01c7f7778180330ed5355195e2d4874e8672a7041deccf0e526/tk_db_utils-0.1.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "19effb5af39dfc09236862b078f4fbffa6a16c164b6c2e3f9de03a3b9897c934",
                "md5": "188f6aacbd6ddf4ab5a292cdd3e235bb",
                "sha256": "c2a38a4b492e78960ad386978608bebf45d0b1a86db00a1c9f4dbfb120ddb00c"
            },
            "downloads": -1,
            "filename": "tk_db_utils-0.1.6.tar.gz",
            "has_sig": false,
            "md5_digest": "188f6aacbd6ddf4ab5a292cdd3e235bb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 65601,
            "upload_time": "2025-08-02T04:31:29",
            "upload_time_iso_8601": "2025-08-02T04:31:29.729197Z",
            "url": "https://files.pythonhosted.org/packages/19/ef/fb5af39dfc09236862b078f4fbffa6a16c164b6c2e3f9de03a3b9897c934/tk_db_utils-0.1.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-02 04:31:29",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "tiankongzhise",
    "github_project": "tk-db-utils#readme",
    "github_not_found": true,
    "lcname": "tk-db-utils"
}
        
Elapsed time: 1.89550s