flask_mysqlpool
This package allows you to use mysql-connector-pythons pooling feature from flask
Usage
import mysql.connector
from flask import Flask, abort, jsonify
from flask_mysqlpool import MySQLPool
app = Flask(__name__)
app.config['MYSQL_HOST'] = 'localhost'
app.config['MYSQL_PORT'] = 3306
app.config['MYSQL_USER'] = 'test'
app.config['MYSQL_PASS'] = 'test'
app.config['MYSQL_DB'] = 'world_x'
app.config['MYSQL_POOL_NAME'] = 'mysql_pool'
app.config['MYSQL_POOL_SIZE'] = 5
app.config['MYSQL_AUTOCOMMIT'] = True
db = MySQLPool(app)
@app.route('/')
def index():
try:
conn = db.connection.get_connection() # get connection from pool
cursor = conn.cursor(dictionary=True)
cursor.execute("select * from world_x.city limit 10", )
result = cursor.fetchall()
conn.close() # return connection to pool
return jsonify(result)
except mysql.connector.ProgrammingError as err:
print(err)
abort(500)
Metadata
Release files for flask-mysqlpool 1.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| flask_mysqlpool-1.0.5.tar.gz | 3.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| flask_mysqlpool-1.0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.7 kB
Release files / flask_mysqlpool-1.0.5.tar.gz
| Download URL | flask_mysqlpool-1.0.5.tar.gz |
|---|---|
| Size | 3.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5cfb3c7603034cc2fa0ecc564f71232751cb10ef3081bf8f238c25486b3700c8
|
|
BLAKE2b-256 checksum How to use checksums |
9411863f16c4835dc25309cc8c9ef4b6340a92c8f513f38dbe08b8622bf9f90d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.5
|
Release files / flask_mysqlpool-1.0.5-py3-none-any.whl
| Download URL | flask_mysqlpool-1.0.5-py3-none-any.whl |
|---|---|
| Size | 3.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
92dd9cc01c5dde6c46edcb5fa2b1086cc3de91ff008e77728ce1ec9d8102825f
|
|
BLAKE2b-256 checksum How to use checksums |
ee5f9d53030261f842a11b631d26cc673344d1d254cd4092660e3630504fde25
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.5
|