简单易用的 mysql 封装
Project description
EaseMySQL
一个简单易用的MySQL封装库,帮助开发者更高效地处理MySQL数据库操作。
主要功能
- 数据库连接池管理
- 简化的CRUD操作接口
- SQL语句构建辅助函数
- 支持参数化查询,防止SQL注入
- 单例模式确保每个连接配置只创建一个连接池
安装方法
pip install --upgrade easemysql -i https://pypi.org/simple/
依赖的库
pip install pymysql --upgrade
pip install DBUtils --upgrade
快速开始
from easemysql import EaseMySQL
# 配置数据库连接
config = dict(host='localhost', user='username', password='password', database='dbname')
db = EaseMySQL(**config)
# 查询单条记录
result = db.one('table_name', dict(id=1))
# 查询多条记录
results = db.all('table_name', 'status = ?', [1])
# 使用条件列表进行复杂查询
results = db.all('table_name', [
'or',
['in', 'id', [1, 3, 4]],
['and', ['>', 'id', 5], 'id < 8', dict(id=[6, 7])],
dict(id=8),
dict(id=[9]),
])
# 插入记录
db.insert('table_name', dict(name='test', value=123))
# 更新记录
db.update('table_name', dict(value=456), 'id = 1')
# 删除记录
db.delete('table_name', 'id = 1')
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
easemysql-1.0.10.tar.gz
(8.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file easemysql-1.0.10.tar.gz.
File metadata
- Download URL: easemysql-1.0.10.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1eb5b2c672563a59b0ccea5f99f0c798aca0bbb52a7126ba72e2c0453d6cabf3
|
|
| MD5 |
ccd083476a4a28b1d922c7c21a8558f7
|
|
| BLAKE2b-256 |
8fcdc4bd40bffb5bc439ba5470d2f3241957b96bcccab172ee0644a4401f7225
|
File details
Details for the file easemysql-1.0.10-py3-none-any.whl.
File metadata
- Download URL: easemysql-1.0.10-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a70b3e500e58b07e94bbd688e9732c2cf6b22a4339ccb5a10547c056a22ff017
|
|
| MD5 |
3c83739722283668ce0a5d31c4ea02e9
|
|
| BLAKE2b-256 |
f2b12a4ede1f74448ae396a91998c6f9ab80fca650e86d1ffc5c665f3238da0d
|