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://asyncdb.gcm.cz/

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.1.3.tar.gz (41.0 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.1.3-py3-none-any.whl (49.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gcm_asyncdb-2.1.3.tar.gz
  • Upload date:
  • Size: 41.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.9 Linux/5.4.0-204-generic

File hashes

Hashes for gcm_asyncdb-2.1.3.tar.gz
Algorithm Hash digest
SHA256 5ddec3ebe9c5a0c2f04a8bb014666fcfd2175fe4c8cca1136c8d1e7ad535a5b1
MD5 2efbe2b233ba8753159776b9ad97671c
BLAKE2b-256 830b2a8c74ddaaa88c77dc3be1e5e6e013b745a639888dd4e5b8af45116495a2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gcm_asyncdb-2.1.3-py3-none-any.whl
  • Upload date:
  • Size: 49.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.9 Linux/5.4.0-204-generic

File hashes

Hashes for gcm_asyncdb-2.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 33df72b514d99adfa90ddc103aba32c86f0e96eb534307da17feb628f486d693
MD5 6e421d7d14b6f54e42a8039adf8f50a2
BLAKE2b-256 2f1b4253bce5c0d7c18be79c7c4804be8d891da7da5c6a6b92bf7ef0a4774ef5

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