Fast MySQL driver build in Cython (Sync and Async).
Project description
Fast MySQL driver build in Cython (Sync and Async).
Created to be used in a project, this package is published to github for ease of management and installation across different modules.
Installation
Install from PyPi
pip install sqlcycli
Install from github
pip install git+https://github.com/AresJef/SQLCyCli.git
Requirements
- Python 3.10 or higher.
- MySQL 5.5 or higher.
Features
- Written in Cython for optimal performance (especially for SELECT/INSERT query).
- All classes and methods are well documented and static typed.
- Supports both
SyncandAsyncconnection to the server. - API Compatiable with PyMySQL and aiomysql.
- Support conversion (escape) for most of the native python types, and objects from libaray numpy and pandas. Does
NOTsupport custom conversion (escape).
Benchmark
The following result comes from benchmark:
- Device: MacbookPro M1Pro(2E8P) 32GB
- Python: 3.12.4
- MySQL: 8.3.0
- mysqlclient: 2.2.4
- PyMySQL: 1.1.1
- aiomysql: 0.2.0
- asyncmy: 0.2.9
# Unit: second | Lower is better
name type rows insert-per-row insert-bulk select-per-row select-all update-per-row update-all delete-per-row delete-all
mysqlclient sync 50000 1.734200 0.427027 1.756226 0.117552 1.901870 0.365056 1.651022 0.131151
SQLCyCli sync 50000 2.203967 0.293410 2.331576 0.062152 2.279076 0.352106 2.115025 0.107902
PyMySQL sync 50000 2.607349 0.412063 4.219286 0.321089 2.572826 0.345419 2.304015 0.104720
SQLCyCli async 50000 3.342991 0.270254 4.297667 0.141201 3.466729 0.346168 3.343880 0.105293
aiomysql async 50000 3.464662 0.384193 5.115068 0.322858 3.582689 0.345661 3.444377 0.104894
asyncmy async 50000 3.851011 0.416715 5.604330 0.314939 3.824736 0.346903 3.580444 0.104748
Usage
Use connect() to create one connection (Sync or Async) to the server.
import asyncio
import sqlcycli
HOST = "localhost"
PORT = 3306
USER = "root"
PSWD = "password"
# Synchronous Connection
def test_sync_connection() -> None:
with sqlcycli.connect(HOST, PORT, USER, PSWD) as conn:
with conn.cursor() as cur:
cur.execute("SELECT 1")
res = cur.fetchone()
assert res == (1,)
# Connection closed
assert conn.closed()
# Asynchronous Connection
async def test_async_connection() -> None:
async with sqlcycli.connect(HOST, PORT, USER, PSWD) as conn:
async with conn.cursor() as cur:
await cur.execute("SELECT 1")
res = await cur.fetchone()
assert res == (1,)
# Connection closed
assert conn.closed()
if __name__ == "__main__":
test_sync_connection()
asyncio.run(test_async_connection())
Use create_pool() to create a Pool for managing and maintaining Async connections to the server.
import asyncio
import sqlcycli
HOST = "localhost"
PORT = 3306
USER = "root"
PSWD = "password"
# Pool (Context Manager: Connected)
async def test_pool_context_connected() -> None:
async with sqlcycli.create_pool(HOST, PORT, USER, PSWD, min_size=1) as pool:
# Pool is connected: 1 free connection (min_size=1)
assert not pool.closed() and pool.free == 1
async with pool.acquire() as conn:
async with conn.cursor() as cur:
await cur.execute("SELECT 1")
res = await cur.fetchone()
assert res == (1,)
# Pool closed
assert pool.closed() and pool.total == 0
# Pool (Context Manager: Disconnected)
async def test_pool_context_disconnected() -> None:
with sqlcycli.create_pool(HOST, PORT, USER, PSWD, min_size=1) as pool:
# Pool is not connected: 0 free connection (min_size=1)
assert pool.closed() and pool.free == 0
# Connect automatically
async with pool.acquire() as conn:
async with conn.cursor() as cur:
await cur.execute("SELECT 1")
res = await cur.fetchone()
assert res == (1,)
# 1 free connection
assert pool.free == 1
# Pool closed
assert pool.closed() and pool.total == 0
# Pool (Create Directly: Connected)
async def test_pool_direct_connected() -> None:
pool = await sqlcycli.create_pool(HOST, PORT, USER, PSWD, min_size=1)
# Pool is connected: 1 free connection (min_size=1)
assert not pool.closed() and pool.free == 1
async with pool.acquire() as conn:
async with conn.cursor() as cur:
await cur.execute("SELECT 1")
res = await cur.fetchone()
assert res == (1,)
# Close pool manually
await pool.close()
assert pool.closed() and pool.total == 0
if __name__ == "__main__":
asyncio.run(test_pool_context_connected())
asyncio.run(test_pool_context_disconnected())
asyncio.run(test_pool_direct_connected())
Acknowledgements
SQLCyCli is build on top of the following open-source repositories:
SQLCyCli is based on the following open-source repositories:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sqlcycli-1.0.1.tar.gz.
File metadata
- Download URL: sqlcycli-1.0.1.tar.gz
- Upload date:
- Size: 2.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc5c804761874991bb53f3e5105dd731136c8762dadf8207ac392aea4d85d225
|
|
| MD5 |
092105d2d233fd3fdacfc63c3b12d82e
|
|
| BLAKE2b-256 |
d5ae85c913c10d0f523c4a098db5c72f0c81906979878635aad1b731ae31151e
|
File details
Details for the file sqlcycli-1.0.1-cp312-cp312-win_arm64.whl.
File metadata
- Download URL: sqlcycli-1.0.1-cp312-cp312-win_arm64.whl
- Upload date:
- Size: 3.6 MB
- Tags: CPython 3.12, Windows ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be05dfccce190cbc2cf2cd128730bdf2b04cd61cc82be4321331df20faff8609
|
|
| MD5 |
f8999c43cee5f56ccb06daa869bac20a
|
|
| BLAKE2b-256 |
5a26187149b0271d08f5287099602e9789b1077902583d3927b608bf5093c783
|
File details
Details for the file sqlcycli-1.0.1-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: sqlcycli-1.0.1-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 3.8 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f7edbb3e793c3622c7b1e154830c6da74e81082dc28ffdf8ea6e39a7baef9ad8
|
|
| MD5 |
5776b13cfa45660ed338de648e84d8f7
|
|
| BLAKE2b-256 |
be812eca72dd2a9123b79e4f598ce76ad3e801e627a6c9aceb33e71dbda5749f
|
File details
Details for the file sqlcycli-1.0.1-cp312-cp312-musllinux_1_1_x86_64.whl.
File metadata
- Download URL: sqlcycli-1.0.1-cp312-cp312-musllinux_1_1_x86_64.whl
- Upload date:
- Size: 11.1 MB
- Tags: CPython 3.12, musllinux: musl 1.1+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
026b684fbe1b3cd78f4b1e72352cf940240c023a68d092a6cbca456e5f03f1dc
|
|
| MD5 |
4a939e60898c25f949c66ec081c4feda
|
|
| BLAKE2b-256 |
6123cb177886ffdb0ce15d4ab1180aaba3527316d193d8d99d81d4289d16648d
|
File details
Details for the file sqlcycli-1.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: sqlcycli-1.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 11.1 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f2547d7976c3f913eddd35d5bb41433d9155912f31b78cc32f2465382978769
|
|
| MD5 |
047b0b40a07aebdc0ca0ef5dc5d50e1f
|
|
| BLAKE2b-256 |
35a5ee35f808fa523603c9fe4c8b9163febd29b931989cede338a8481c382d71
|
File details
Details for the file sqlcycli-1.0.1-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: sqlcycli-1.0.1-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 3.9 MB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f1f794ffed9cf8f3930c135a1bad0669677b6894cd9e4709222468a1e3299f04
|
|
| MD5 |
ff8678606d43c73d77c5a50f131809c7
|
|
| BLAKE2b-256 |
9b4d85c6f9707c7faadcf5e3321b970c61b5b90a96d89702367ea125b1edb1b6
|
File details
Details for the file sqlcycli-1.0.1-cp312-cp312-macosx_10_9_x86_64.whl.
File metadata
- Download URL: sqlcycli-1.0.1-cp312-cp312-macosx_10_9_x86_64.whl
- Upload date:
- Size: 4.0 MB
- Tags: CPython 3.12, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4bbce9d0540b21a03f2e2aed93ae6fc1d7c9f17b0530f145f5590f67f95523ff
|
|
| MD5 |
bd3730c3903d90077f7e8855b34f4c2a
|
|
| BLAKE2b-256 |
5dca787c900767792309e577692d3cc1747769804999219eddae3f082ed9f210
|
File details
Details for the file sqlcycli-1.0.1-cp312-cp312-macosx_10_9_universal2.whl.
File metadata
- Download URL: sqlcycli-1.0.1-cp312-cp312-macosx_10_9_universal2.whl
- Upload date:
- Size: 5.3 MB
- Tags: CPython 3.12, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5893bf46029655d79b26c170feb1eecc8257c2156218dcdca11d584ddfa58d22
|
|
| MD5 |
3b95410c34f99f9108f1d2a12051f1bc
|
|
| BLAKE2b-256 |
769075d92d6437c27c97ab49e9531edfd4e3ae07cb08b7f4e9fd8e7c31434855
|
File details
Details for the file sqlcycli-1.0.1-cp311-cp311-win_arm64.whl.
File metadata
- Download URL: sqlcycli-1.0.1-cp311-cp311-win_arm64.whl
- Upload date:
- Size: 3.6 MB
- Tags: CPython 3.11, Windows ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2722700d16b4f359af0ee8dcc22c470f60434ee940bb426269a4e28a444e6f5a
|
|
| MD5 |
12a5c6aee67bd9a5446864a62c560ab5
|
|
| BLAKE2b-256 |
4fd3ffd5b3d0f54800165f9abdde3d2188b7e6b3e285261da548dcff66555cf8
|
File details
Details for the file sqlcycli-1.0.1-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: sqlcycli-1.0.1-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 3.8 MB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d7cb3488b796b33a047a8d186e4563309ff72b3697c54b301a1dc747084bf965
|
|
| MD5 |
d0c665ebb2f85c2fc43effb8b76e2b46
|
|
| BLAKE2b-256 |
9ad9c72a5e291e183088ac911d249aca5e9e81cd8625fa129fcffd2e0752f889
|
File details
Details for the file sqlcycli-1.0.1-cp311-cp311-musllinux_1_1_x86_64.whl.
File metadata
- Download URL: sqlcycli-1.0.1-cp311-cp311-musllinux_1_1_x86_64.whl
- Upload date:
- Size: 11.2 MB
- Tags: CPython 3.11, musllinux: musl 1.1+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b567b9b34d2224e1e15ebe17725a7ccd60a3fba8be7d5d49d4f1942d724e670
|
|
| MD5 |
69836c25ca16e16b378ea635960a0c2b
|
|
| BLAKE2b-256 |
5af2b90d9ec4517d65d7b97df2763c69de1f04ee3a2cd5583983725c497894bd
|
File details
Details for the file sqlcycli-1.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: sqlcycli-1.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 11.1 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
699799932756d16c5d355f3fd9ddba4ab373e40bc20927940df4d26e981eab3b
|
|
| MD5 |
f3f9e7f60d01557144097696c5ab2791
|
|
| BLAKE2b-256 |
b1d3bda403ea29d7fb90c4dc246b6693d6a1629880b7d151d5cb92a85f08efda
|
File details
Details for the file sqlcycli-1.0.1-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: sqlcycli-1.0.1-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 3.9 MB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c907f5ad412728e05bb7feae3a19043a08928cf19b4a1dd11e64251f98104f95
|
|
| MD5 |
69c0a274d6e8cf590798cf62673a8a47
|
|
| BLAKE2b-256 |
44f698662e9f875989970788a840ac174c47a1197b64c2052a4e130d5a147940
|
File details
Details for the file sqlcycli-1.0.1-cp311-cp311-macosx_10_9_x86_64.whl.
File metadata
- Download URL: sqlcycli-1.0.1-cp311-cp311-macosx_10_9_x86_64.whl
- Upload date:
- Size: 4.0 MB
- Tags: CPython 3.11, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
41f964087849143e82fd55659896318a1bbb57506880aca917abfe25dc2fe20e
|
|
| MD5 |
371ae04a65e59068c5d819ba6bfd21d6
|
|
| BLAKE2b-256 |
1b1c2ba3276eb50e4959cc3f2e1bba00c96727788e03538c1e53b424d2ce93b9
|
File details
Details for the file sqlcycli-1.0.1-cp311-cp311-macosx_10_9_universal2.whl.
File metadata
- Download URL: sqlcycli-1.0.1-cp311-cp311-macosx_10_9_universal2.whl
- Upload date:
- Size: 5.3 MB
- Tags: CPython 3.11, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2053f9b7bb549d9f4c26c437f450c1b1141509d24ae15fc8c2e1cab2f2a36aa4
|
|
| MD5 |
87ca7a0ec702d53b5292c0dcaf9b888c
|
|
| BLAKE2b-256 |
2220b79e98ff9ae4b9b742df5cf7ac066935ec46282e02ef4d6b1fb54877f078
|
File details
Details for the file sqlcycli-1.0.1-cp310-cp310-win_arm64.whl.
File metadata
- Download URL: sqlcycli-1.0.1-cp310-cp310-win_arm64.whl
- Upload date:
- Size: 3.6 MB
- Tags: CPython 3.10, Windows ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b01082b731046a040f2f8c6a976330621b54e6049947822255bc749b2d447a88
|
|
| MD5 |
a51a4ac8aef16d270d198ee39930f568
|
|
| BLAKE2b-256 |
3d62336fd2e52743cff3ed69706f487ebbf599d0f4fa425a6ea162f3845b3b4a
|
File details
Details for the file sqlcycli-1.0.1-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: sqlcycli-1.0.1-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 3.8 MB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a568d01ac3a9b4955904a18b763b3dea8b4d9eb589ecc83bcc424498a44c04f
|
|
| MD5 |
ed2ec8888f06b8240225a8828ce2df4d
|
|
| BLAKE2b-256 |
7770e505f25dcb271f56a1c2089f357ac9a2b7b6d4b6db7a677f6ee26b2a9e82
|
File details
Details for the file sqlcycli-1.0.1-cp310-cp310-musllinux_1_1_x86_64.whl.
File metadata
- Download URL: sqlcycli-1.0.1-cp310-cp310-musllinux_1_1_x86_64.whl
- Upload date:
- Size: 10.5 MB
- Tags: CPython 3.10, musllinux: musl 1.1+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d869d13006389b193a68ef8f843d04a396f3441f51728fd6670a4a37463e4517
|
|
| MD5 |
3a3c0fd0e938af5db6580d0fdf0d1d5a
|
|
| BLAKE2b-256 |
c3e61180fc74427e9862a8690821ec8ead66625bd9d22038f628d81b79a4732a
|
File details
Details for the file sqlcycli-1.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: sqlcycli-1.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 10.4 MB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f01ace5c897c01be646eab92ca7e7874ee02bf9f7095dd1ba6cbc9de797ce381
|
|
| MD5 |
7f1025bcf61b038cf695af813c523b38
|
|
| BLAKE2b-256 |
1e6281892dddf0a7ac50d7c285985a1a3e72cd3d9e532e039e8a7b21e324aeba
|
File details
Details for the file sqlcycli-1.0.1-cp310-cp310-macosx_11_0_arm64.whl.
File metadata
- Download URL: sqlcycli-1.0.1-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 3.9 MB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e6e8b792aeb3967d6871086c7712bb26586aa3a586f8821c4f20d603d4438c4
|
|
| MD5 |
d6cd1dcc027aa3ae68635aca230579ca
|
|
| BLAKE2b-256 |
4223ca9a7cad3cb773e49a03df7d4517aef1538e670e0ab4a7c7b045f9fd16b1
|
File details
Details for the file sqlcycli-1.0.1-cp310-cp310-macosx_10_9_x86_64.whl.
File metadata
- Download URL: sqlcycli-1.0.1-cp310-cp310-macosx_10_9_x86_64.whl
- Upload date:
- Size: 4.0 MB
- Tags: CPython 3.10, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6040a87aff686a2c03dc69d905e89ae2fac7bf5b6233952b0bc27464a128a217
|
|
| MD5 |
c445ab2463bb6adad905a521b770ea4b
|
|
| BLAKE2b-256 |
7b3179d79eec52f3cd1a6bc43307742ec28913fe865658045d692fd0ae4410a1
|
File details
Details for the file sqlcycli-1.0.1-cp310-cp310-macosx_10_9_universal2.whl.
File metadata
- Download URL: sqlcycli-1.0.1-cp310-cp310-macosx_10_9_universal2.whl
- Upload date:
- Size: 5.3 MB
- Tags: CPython 3.10, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4784c542105731c4690292a8b421a646f0cbeb422519dad43e5ea969cdedfc29
|
|
| MD5 |
6b568795d98935e2750ff8130b52ffdf
|
|
| BLAKE2b-256 |
2ad4bb7d1d8df10153ff0133f344767d453a7a922a23895c199ad19739e4d16b
|