make it easy to use pymysql
Project description
fastmysql
介绍
简单快速的使用mysql
软件架构
软件架构说明
安装教程
- pip安装
pip3 install fastmysql
- pip安装(使用淘宝镜像加速)
pip3 install fastmysql -i https://mirrors.aliyun.com/pypi/simple
使用说明
- 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'
)
- 防止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表都查询出来
- 默认环境
- 默认使用的环境文件为:mysql.env
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
fastmysql-0.2.29.tar.gz
(17.2 kB
view hashes)
Built Distribution
fastmysql-0.2.29-py3-none-any.whl
(17.9 kB
view hashes)
Close
Hashes for fastmysql-0.2.29-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68e02c4aea7e701c70a0e1791bf9dc3f9f9b5c11208d16ea2e23f66a8ee3274f |
|
MD5 | 9625f3ab866e5ca8f8a07731ac457ece |
|
BLAKE2b-256 | af510001bb4c8b26c4f2203ea837a753b12df2b86053189a8935f5500c8bf0b2 |