A library that makes MySQL operation more convenient.
Project description
PyMysqlTools
PyMysqlTools 是一个使用封装好的函数替代SQL语句来操作mysql的工具库
环境配置
PyMysqlTools 目前支持 Python3.6+ 且 MySQL5.6+ 版本
快速开始
-
下载本项目
pip install PyMysqlTools
-
导入本项目到您的代码
import PyMysqlTools
-
建立连接
import PyMysqlTools # 可以使用下面的示例代码直接获得一个mysql数据库的连接 mysql = PyMysqlTools.connect( database='db_test', username='root', password='123456' ) print(mysql) # <PyMysqlTools.main.Connect object>
-
简单使用
-
添加数据
# 准备待添加的数据, 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)
-
关于
如果您在使用时遇到了意料之外的结果,请提交Issue帮助我们改进此项目。
Thanks
本项目在开发中使用了以下Python库
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.6.3.tar.gz
(10.4 kB
view hashes)
Built Distribution
Close
Hashes for PyMysqlTools-0.6.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9177a41ea803f0a7b320a6651dedaad591b4bbc0cabadd227f6bc0ed4c3fa40 |
|
MD5 | 785f02d1931dacc6df662b8f988ca8f8 |
|
BLAKE2b-256 | e1ccd597e7f1597d23f5ea82a2394582cc675c1bd93323d5222b81e004ee839d |