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
Built Distribution
File details
Details for the file fastmysql-0.3.1.tar.gz
.
File metadata
- Download URL: fastmysql-0.3.1.tar.gz
- Upload date:
- Size: 18.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b14990482b97c125a28848351df309593aa82155790695bd48c56ac979413c47 |
|
MD5 | 679907f9012a3a16cf349d36cbb2cd98 |
|
BLAKE2b-256 | e57e504a6ee5fc2180c15ff0e3d5f91641867461ad92d545121bcb3ba2c9e5d8 |
Provenance
File details
Details for the file fastmysql-0.3.1-py3-none-any.whl
.
File metadata
- Download URL: fastmysql-0.3.1-py3-none-any.whl
- Upload date:
- Size: 19.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 70b2431f6e95f59ba72bbaa13e7df042cd12a6145462a14a18f4e0d251d79bdf |
|
MD5 | fd5a7afa855a603e9bef61b49d59e938 |
|
BLAKE2b-256 | 6a4b7f27a4328ea6df9ae22e9334e1878222f2be7e82f4f14fec2b851862daa1 |