Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

flask-mysql-connector

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flask-mysql-connector

Easy to use MySQL client for Flask apps.

  • 1.1.0
  • PyPI
  • Socket score

Maintainers
1

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
ParamDefault Value
MYSQL_USER
MYSQL_PASSWORD
MYSQL_DATABASE
MYSQL_HOST127.0.0.1
MYSQL_PORT3306
MYSQL_UNIX_SOCKET
MYSQL_AUTH_PLUGIN
MYSQL_USE_UNICODETRUE
MYSQL_CHARSETutf8
MYSQL_COLLATION
MYSQL_AUTOCOMMITFALSE
MYSQL_TIME_ZONE
MYSQL_SQL_MODE
MYSQL_GET_WARNINGSFALSE
MYSQL_RAISE_ON_WARNINGSFALSE
MYSQL_CONNECTION_TIMEOUT
MYSQL_CLIENT_FLAGS
MYSQL_BUFFEREDFALSE
MYSQL_RAWFALSE
MYSQL_CONSUME_RESULTSFALSE
MYSQL_SSL_CA
MYSQL_SSL_CERT
MYSQL_SSL_DISABLEDFALSE
MYSQL_SSL_KEY
MYSQL_SSL_VERIFY_CERTFALSE
MYSQL_SSL_VERIFY_IDENTITYFALSE
MYSQL_FORCE_IPV6FALSE
MYSQL_DSN
MYSQL_POOL_NAME
MYSQL_POOL_SIZE5
MYSQL_POOL_RESET_SESSIONTRUE
MYSQL_COMPRESSFALSE
MYSQL_CONVERTER_CLASS
MYSQL_FAILOVER
MYSQL_OPTION_FILES
MYSQL_OPTION_GROUPS
MYSQL_ALLOW_LOCAL_INFILETRUE
MYSQL_USE_PURE

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc