Skip to main content

Alternative approach to database API with full native async support and connection pool.

Project description

gcm-asyncdb

This library provides better, more robust database API with strong enforcement of transaction logic when working with relational databases.

Currently, only MySQL (aiomysql) is supported, but support for other databases should be easy to implement, when required.

Documentation

API documentation is available at https://gcm-cz.gitlab.io/gcm-asyncdb

Installation

pip install gcm-asyncdb

Usage

from asyncdb.aiomysql import TransactionFactory, MySQLConfig

db = TransactionFactory(MySQLConfig(
    host='localhost',
    user='root',
    database='test'
))

async def main():
    async with db.transaction() as t:
        await t.query('CREATE TABLE test (id INT PRIMARY KEY, name VARCHAR(255))')
        await t.query('INSERT INTO test (id, name) VALUES (1, "test")')
        result = await t.query('SELECT * FROM test')
        async for row in result.fetch_all_dict():
            print(row)

        await t.commit()

License

MIT

Maturity

This library is still very new, but grew from multiple projects where it gradually evolved. So it is already used in production, but it is still recommended to test it thoroughly before using it in production.

Historically, there has been problems with losing connections from connection pool in rare unpredictable error cases, it seems to be resolved now, but there is no regression test for this, so be careful.

Contributing

Feel free to open an issue or a pull request.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gcm_asyncdb-2.3.1.tar.gz (45.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gcm_asyncdb-2.3.1-py3-none-any.whl (55.2 kB view details)

Uploaded Python 3

File details

Details for the file gcm_asyncdb-2.3.1.tar.gz.

File metadata

  • Download URL: gcm_asyncdb-2.3.1.tar.gz
  • Upload date:
  • Size: 45.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.11.14 Linux/6.8.0-90-generic

File hashes

Hashes for gcm_asyncdb-2.3.1.tar.gz
Algorithm Hash digest
SHA256 870146ac337d9d42ba847962976b06dca06ea5256569526790ae28468fdcf473
MD5 295564765df4d599b2390b0339032ac4
BLAKE2b-256 027a7abbcc4b6e448c01fa650ffdeeee3acef6b2d3f4272300f4e8ecab2a1d46

See more details on using hashes here.

File details

Details for the file gcm_asyncdb-2.3.1-py3-none-any.whl.

File metadata

  • Download URL: gcm_asyncdb-2.3.1-py3-none-any.whl
  • Upload date:
  • Size: 55.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.11.14 Linux/6.8.0-90-generic

File hashes

Hashes for gcm_asyncdb-2.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 319e998f3213775be9de757c54b253a1fe5708290f8fe70be15d9ca200f3f913
MD5 804dc664fae13aa255ca4850162dd090
BLAKE2b-256 b5c98f6a1eca4b412e3e3e91ed6b82ad4d3e7202084c19f496170b3ea40b394d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page