1 Star 1 Fork 0

pikachu / PyMysqlTools

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

PyMysqlTools

PyMysqlTools 是一个使用封装好的函数替代SQL语句来操作mysql的工具库

环境配置

PyMysqlTools 目前支持 Python3.6+ 且 MySQL5.6+ 版本

快速开始

  • 下载本项目

    pip install PyMysqlTools
  • 导入本项目到您的代码

    import PyMysqlTools
  1. 建立连接

    import PyMysqlTools
    
    # 可以使用下面的示例代码直接获得一个mysql数据库的连接
    mysql = PyMysqlTools.connect(
        database='db_test',
        username='root',
        password='123456'
    )
    print(mysql) # <PyMysqlTools.main.Connect object>
  2. 简单使用

    • 添加数据

      # 准备待添加的数据, 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库

MIT License Copyright (c) 2022 ulala Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

PyMysqlTools 是一个通过避免编写SQL语句的方式来操作mysql的工具库 展开 收起
Python
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Python
1
https://gitee.com/uraurara/PyMysqlTools.git
git@gitee.com:uraurara/PyMysqlTools.git
uraurara
PyMysqlTools
PyMysqlTools
master

搜索帮助