A library that makes MySQL operation more convenient.
Project description
PyMysqlTools
PyMysqlTools 是一个能以更方便的方式来操作mysql的库
注意
PyMysqlTools 目前仅支持 Python3.6+ 且 MySQL5.6+ 版本
快速开始
-
下载本项目
pip install PyMysqlTools
-
导入本项目到您的代码
import PyMysqlTools
-
建立连接
import PyMysqlTools mysql = PyMysqlTools.connect( database='db_test', username='root', password='123456' ) print(mysql) # 可以使用上面的示例代码获得一个mysql数据库的连接
-
简单使用
-
添加数据
# 准备待添加的数据, key=字段名, value=字段值 data = { 'username': 'abc', 'password': 'abc123' } # 添加数据到数据表 mysql.insert_one('tb_test', data)
-
删除数据
# 根据id删除数据 mysql.delete_by_id('tb_test', 2)
-
修改数据
# 准备待修改的数据, key=字段名, value=字段值 data = { 'username': 'abc', 'password': 'abc123' } # 修改数据表中的数据 mysql.update_by_id('tb_test', data, 3)
-
查询数据
# 查询全表数据并遍历输出 for row in mysql.find_all('tb_test'): print(row)
-
其他更多方法详见 api 文档
- ps: api文档目前还没有。
-
关于社区
如果您在使用时遇到了意料之外的结果,请提交Issue帮助我们改进此项目。
Thanks
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
PyMysqlTools-0.5.15.tar.gz
(12.3 kB
view hashes)
Built Distribution
Close
Hashes for PyMysqlTools-0.5.15-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7345b2c8c227dbbee1b88e2ef0fcc4b6f8abee350009e16836f8ca8ef9029c8 |
|
MD5 | c5a9081b1b778c076ed4be913cb0a44d |
|
BLAKE2b-256 | eb1e92862dd4c4d78f49d8a22b0fbc9b5d19b7d5fbd982c005b1a6e8fe192e13 |