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

flask-mysqlpool

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flask-mysqlpool

Wrapper for mysql.connector.python to get a pool of mysql connections

  • 1.0.5
  • PyPI
  • Socket score

Maintainers
1

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)

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