Skip to main content

简单易用的 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


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.3.0.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

easemysql-1.3.0-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

Details for the file easemysql-1.3.0.tar.gz.

File metadata

  • Download URL: easemysql-1.3.0.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for easemysql-1.3.0.tar.gz
Algorithm Hash digest
SHA256 a7dccb1359522f4c555862a78f42aac3fb0be0bb702cba7c50fac0bb80fd13dc
MD5 9c49d2bc9218d56c86fcf884e52be3d3
BLAKE2b-256 484e595859f9acb73fcca88126235d0c01f5bb28525101d01f5d84caf345b246

See more details on using hashes here.

File details

Details for the file easemysql-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: easemysql-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 11.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for easemysql-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e039c537d36d32a39c2b43879ec5f4496fb12373d188c06c5b6caf1fb94a8e9c
MD5 07d8753ff4b5e0b40d29965a738412cb
BLAKE2b-256 4ccf4ce1f64871849fbc188e1f7a4f1b64f348c8d0a3e921cd26e932b4e4d995

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page