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.2.19.tar.gz (16.5 kB view details)

Uploaded Source

Built Distribution

fastmysql-0.2.19-py3-none-any.whl (17.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fastmysql-0.2.19.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for fastmysql-0.2.19.tar.gz
Algorithm Hash digest
SHA256 8dc766ad37d6a99425bc3fd7a013637164c371ac8c79bf761cc692a55eb6a879
MD5 4f5f02cb0f482b8c1f07cccbb7a4f2a7
BLAKE2b-256 61a62caefb43d026f897e8c81f8ca999508b09312f8cd249c686793c4ea0c637

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: fastmysql-0.2.19-py3-none-any.whl
  • Upload date:
  • Size: 17.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for fastmysql-0.2.19-py3-none-any.whl
Algorithm Hash digest
SHA256 ecdba71a5cd906968f3221fd218b5032e7d8b3fde0c870aad65aa1eef3d68435
MD5 0340ef8899f49f56230ae008bdbc14fb
BLAKE2b-256 cdaeb55851a3e9953004e2a9396dd8fc65642717588b6d2dbb2fdb7f80060bd0

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page