Skip to main content

PyMySQLPool

build status codecov pip version license

PyMySQLPool is a pymysql-based database connection pool, simple and lightweight.

Table of content

Features

  • Maintain a minimum number of connection pools by default.
  • If a number of unuse connections less than zero, dynamically add connections to pool until the current number of inuse connections equal maximum of the pool.
  • Release the idle connections in regular until a number of unuse connections equal minimum of the pool.
  • Support auto-commit mode.
  • Support for ping check to get healthy connections.

Requirements

  • Python
    • CPython : >= 3.4
  • MySQL Server -- one of the following:
    • MySQL >= 5.5
    • MariaDB >= 5.5
  • PyMySQL: >= 0.9.2

Installation

Package is uploaded on PyPI

You can install with pip

$ pip install pymysql-pooling

Example

Make use of a simple table (Example in MySQL doc)

mysql> CREATE TABLE pet (name VARCHAR(20), owner VARCHAR(20),
    -> species VARCHAR(20), sex CHAR(1), birth DATE, death DATE);

mysql> INSERT INTO pet
    -> VALUES ("Puffball", "Diane", "hamster", "f", "1999-03-30", NULL);
from pymysqlpool.pool import Pool


# Note: you can also add any parameters relates to `pymysql.connections.Connection` object
pool = Pool(host=HOST, port=PORT, user=USER, password=PASSWORD, db=DB)
pool.init()

connection = pool.get_conn()
cur = connection.cursor()
cur.execute('SELECT * FROM `pet` WHERE `name`=%s', args=("Puffball", ))
print(cur.fetchone())

pool.release(connection)

This example will print:

('Puffball', 'Diane', 'hamster', 'f', datetime.date(1999, 3, 30), None)

Support autocommit mode, as following:

pool = Pool(host=HOST, port=PORT, user=USER, password=PASSWORD, db=DB, autocommit=True)

That's all.

Roadmap

  • Connection Pool
  • Dynamically Create
  • Dynamically Release
  • Monitor Web Interface

Resources

License

PyMySQLPool is released under the MIT License. See LICENSE for more information.

Contributing

Thank you for your interest in the contribution of PyMySQLPool, your help and contribution is very valuable.

You can submit an issue and pull requests, please submit an issue before submitting pull requests.

Metadata

Release files for pymysql-pooling-codingman 1.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pymysql-pooling-codingman 1.0.6
File Size Uploaded
pymysql-pooling-codingman-1.0.6.tar.gz 6.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pymysql-pooling-codingman 1.0.6
File Interpreter ABI Platform
pymysql_pooling_codingman-1.0.6-py3-none-any.whl Python 3 none any Details

Total release size: 13.2 kB

Release files / pymysql-pooling-codingman-1.0.6.tar.gz

Download URL pymysql-pooling-codingman-1.0.6.tar.gz
Size 6.1 kB
Tags Source
SHA-256 checksum
How to use checksums
b05cc0323db873349d11aea149b31a579787cdf01b1447e6fd3c64f2a5b8184f
BLAKE2b-256 checksum
How to use checksums
f18dd717f250659e4c7d4b0d768a13a3c49099ccd20e21f3ff8ccd9a4779b384
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.2

Release files / pymysql_pooling_codingman-1.0.6-py3-none-any.whl

Download URL pymysql_pooling_codingman-1.0.6-py3-none-any.whl
Size 7.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0522ccf423dbb371e3376d8e56a9d1077e61a07d63cb0add1e04b3c7030a6070
BLAKE2b-256 checksum
How to use checksums
bb01b858cd23b6a674df92235fe4f82ba2343667b0050bf415ce816bf0b03471
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.2

Release history Release notifications | RSS feed

This release

1.0.6 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page