Skip to main content

make it easy to use pymysql

Project description

fastmysql

介绍

简单快速的使用mysql

软件架构

软件架构说明

安装教程

  1. pip安装
pip3 install fastmysql
  1. pip安装(使用淘宝镜像加速)
pip3 install fastmysql -i https://mirrors.aliyun.com/pypi/simple

使用说明

  1. demo
import fastmysql
query_res = fastmysql.query_table_all_data(
    db_name='test', 
    tb_name='test'
)

# 获取建表语句
res = fastmysql.show_create_table(
    db_name='test',
    tb_name='test'
)
  1. 防止sql注入: 写法

cursor.execute('insert into user (name,password) value (?,?)',(name,password))   或者

cursor.execute('insert into user (name,password) value (%s,%s)',(name,password))   %s与?都可以作为sql语句的占位符,它们作为占位符的功能是没有区别的,mysql.connector用 %s 作为占位符;pymysql用 ? 作为占位符。但是注意不要写成

cursor.execute('insert into user (name,password) value (?,?)'%(name,password))   这种写法是直接将参数拼接到sql语句中,这样数据库就容易被sql注入攻击,比如

cursor.execute('select * from user where user=%s and password=%s'%(name,password))   要是name和password都等于'a or 1=1',那么这个语句会把整个user表都查询出来

  1. 默认环境
  • 默认使用的环境文件为:mysql.env

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

fastmysql-0.3.7.tar.gz (28.8 kB view details)

Uploaded Source

Built Distribution

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

fastmysql-0.3.7-py3-none-any.whl (33.5 kB view details)

Uploaded Python 3

File details

Details for the file fastmysql-0.3.7.tar.gz.

File metadata

  • Download URL: fastmysql-0.3.7.tar.gz
  • Upload date:
  • Size: 28.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for fastmysql-0.3.7.tar.gz
Algorithm Hash digest
SHA256 f5e1c9f03dfbec03e00cc3dca3b073226248c7379b0c2fcf4d8cf4b79c6456cc
MD5 bdbe22c1baca8ebd78e0a562035eca31
BLAKE2b-256 7122fcd3225e128c9067403c75803e308eec6f043ca4492cf5631c26829431d1

See more details on using hashes here.

File details

Details for the file fastmysql-0.3.7-py3-none-any.whl.

File metadata

  • Download URL: fastmysql-0.3.7-py3-none-any.whl
  • Upload date:
  • Size: 33.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for fastmysql-0.3.7-py3-none-any.whl
Algorithm Hash digest
SHA256 525c5406f3260d25089e363df1b3503ebfa24e203c965b6522897546aad7af15
MD5 cff80fbd3859ac58ad4bd3c382d6e02c
BLAKE2b-256 bee886166ed887ba851dfe2d73e1dec126e9aabd013ba607810b79ae5ae4967b

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