Flask-MySQL-Connector
Easy to use MySQL client for Flask apps.
Install
pip install flask-mysql-connector
Example Usage
from flask import Flask
from flask_mysql_connector import MySQL
app = Flask(__name__)
app.config['MYSQL_USER'] = 'root'
app.config['MYSQL_DATABASE'] = 'sys'
mysql = MySQL(app)
EXAMPLE_SQL = 'select * from sys.user_summary'
# using the new_cursor() method
@app.route('/new_cursor')
def new_cursor():
cur = mysql.new_cursor(dictionary=True)
cur.execute(EXAMPLE_SQL)
output = cur.fetchall()
return str(output)
# using the connection property
@app.route('/connection')
def connection():
conn = mysql.connection
cur = conn.cursor()
cur.execute(EXAMPLE_SQL)
output = cur.fetchall()
return str(output)
# using the execute_sql() method to easily
# select sql and optionally output to Pandas
@app.route('/easy_execute')
def easy_execute():
df = mysql.execute_sql(EXAMPLE_SQL, to_pandas=True)
return str(df.to_dict())
if __name__ == '__main__':
app.run(debug=True)
Availble Config Params
| Param | Default Value |
|---|---|
| MYSQL_USER | |
| MYSQL_PASSWORD | |
| MYSQL_DATABASE | |
| MYSQL_HOST | 127.0.0.1 |
| MYSQL_PORT | 3306 |
| MYSQL_UNIX_SOCKET | |
| MYSQL_AUTH_PLUGIN | |
| MYSQL_USE_UNICODE | TRUE |
| MYSQL_CHARSET | utf8 |
| MYSQL_COLLATION | |
| MYSQL_AUTOCOMMIT | FALSE |
| MYSQL_TIME_ZONE | |
| MYSQL_SQL_MODE | |
| MYSQL_GET_WARNINGS | FALSE |
| MYSQL_RAISE_ON_WARNINGS | FALSE |
| MYSQL_CONNECTION_TIMEOUT | |
| MYSQL_CLIENT_FLAGS | |
| MYSQL_BUFFERED | FALSE |
| MYSQL_RAW | FALSE |
| MYSQL_CONSUME_RESULTS | FALSE |
| MYSQL_SSL_CA | |
| MYSQL_SSL_CERT | |
| MYSQL_SSL_DISABLED | FALSE |
| MYSQL_SSL_KEY | |
| MYSQL_SSL_VERIFY_CERT | FALSE |
| MYSQL_SSL_VERIFY_IDENTITY | FALSE |
| MYSQL_FORCE_IPV6 | FALSE |
| MYSQL_DSN | |
| MYSQL_POOL_NAME | |
| MYSQL_POOL_SIZE | 5 |
| MYSQL_POOL_RESET_SESSION | TRUE |
| MYSQL_COMPRESS | FALSE |
| MYSQL_CONVERTER_CLASS | |
| MYSQL_FAILOVER | |
| MYSQL_OPTION_FILES | |
| MYSQL_OPTION_GROUPS | |
| MYSQL_ALLOW_LOCAL_INFILE | TRUE |
| MYSQL_USE_PURE |
Metadata
Release files for flask-mysql-connector 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| flask_mysql_connector-1.1.0.tar.gz | 4.5 kB | Without provenance | Details for flask_mysql_connector-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| flask_mysql_connector-1.1.0-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for flask_mysql_connector-1.1.0-py2.py3-none-any.whl |
Total release size: 10.3 kB
Release files / flask_mysql_connector-1.1.0.tar.gz
| Download URL | flask_mysql_connector-1.1.0.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ad3c3da148872034d998c12e1d1df3627c86b09322d332219e5769ddc704ab1b
|
|
BLAKE2b-256 checksum How to use checksums |
dcddf5e39c5d45c25ee0f97be29a361553abb6921000e9abe634e571af911c69
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.0
|
Release files / flask_mysql_connector-1.1.0-py2.py3-none-any.whl
| Download URL | flask_mysql_connector-1.1.0-py2.py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
a891fe880ce2140102ffd47d631c8b3b87d04a73987ba5e6683c6cdcad2a5f86
|
|
BLAKE2b-256 checksum How to use checksums |
d6b89d930b598986bd1e4b23dd7b64b56a83d7826fc8636be7548d11ee089b60
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.0
|
Security for flask-mysql-connector 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.