Skip to main content

A library that makes MySQL operation more convenient.

Project description

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库

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

PyMysqlTools-0.6.7.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

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

PyMysqlTools-0.6.7-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file PyMysqlTools-0.6.7.tar.gz.

File metadata

  • Download URL: PyMysqlTools-0.6.7.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.5

File hashes

Hashes for PyMysqlTools-0.6.7.tar.gz
Algorithm Hash digest
SHA256 a6f02770708d2777cfd993989d7acdfde17741ef166dbdee646b05616f7389a2
MD5 3c8b38376f1ec6796d99d898a33344e5
BLAKE2b-256 2fd2ab2327bf4fccb0fc6bd0171ab2d939224fe142c685bda3a94b9fc3006f27

See more details on using hashes here.

File details

Details for the file PyMysqlTools-0.6.7-py3-none-any.whl.

File metadata

  • Download URL: PyMysqlTools-0.6.7-py3-none-any.whl
  • Upload date:
  • Size: 12.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.5

File hashes

Hashes for PyMysqlTools-0.6.7-py3-none-any.whl
Algorithm Hash digest
SHA256 a47a136863f851b4ba568c6ab4e3b5542b95d2ef29b81275c3152c2bfb9bc500
MD5 fda0717ef35bb0fcab633f5b6da539ad
BLAKE2b-256 8cfafbc7496a15c606cdb8dcaf6cdaad7aa08af997c89e0450eb2ffc6d6fe3a0

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