Skip to main content

a anyio and cysqlite library

Project description

PyPI version PyPI - Downloads License: MIT

anyio-cysqlite

A Bidning for cysqlite that makes the database asynchronous with any asynchronous library that can be binded to anyio meaning that it will work with many server implementations and applications including FastAPI, Starlette and Litestar to name a few server libraries.

from anyio_cysqlite import connect


async def main():
    async with await connect("cysqlite.db") as db:
        await db.execute('create table IF NOT EXISTS data (k, v)')

        async with db.atomic():
            await db.executemany('insert into data (k, v) values (?, ?)',
                           [(f'k{i:02d}', f'v{i:02d}') for i in range(10)])
            print(await db.last_insert_rowid())  # 10.

        curs = await db.execute('select * from data')
        async for row in curs:
            print(row)  # e.g., ('k00', 'v00')

        # We can use named parameters with a dict as well.
        row = await db.execute_one('select * from data where k = :key and v = :val',
                             {'key': 'k05', 'val': 'v05'})
        print(row)  # ('k05', 'v05')

        await db.close()

if __name__ == "__main__":
    import anyio
    anyio.run(main)

Updated functionality is better

When it comes to database execution updated functionality normally results in better performance such as providing wrappers for atomic, transaction, and savepoint functions which the standard sqlite3 library doesn't currently have. Instead of having a completely seperate thread for the database all operations are done using the anyio's CapacityLimiter and run_sync making the database less resource heavy.

Batteries included

Unlike cysqlite (As of currently), this library retains access to typehints right out of the box making the library less of a function and attribute guessing game.

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

anyio_cysqlite-0.2.0.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

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

anyio_cysqlite-0.2.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file anyio_cysqlite-0.2.0.tar.gz.

File metadata

  • Download URL: anyio_cysqlite-0.2.0.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for anyio_cysqlite-0.2.0.tar.gz
Algorithm Hash digest
SHA256 a425274dc3f5c8eeb2718c2233bcb16edef34e4d2a8c5d0a566ff83ca4cd4a84
MD5 e47f0f716abae70d1745dcb5251875ce
BLAKE2b-256 1e6bf2235162d8e7118689cb03e2faf6fdae469646204fdc916e30f5639450a7

See more details on using hashes here.

Provenance

The following attestation bundles were made for anyio_cysqlite-0.2.0.tar.gz:

Publisher: python-publish.yml on Vizonex/anyio-cysqlite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file anyio_cysqlite-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: anyio_cysqlite-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for anyio_cysqlite-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 97db836f6e6dd28193b8ad8bc2d9d51f297caf8eed94d2159e282949b5f51ff4
MD5 aaa18caf078d6472bed6555da27eaa85
BLAKE2b-256 f61764b195e52001ee721bc06108e7eefa47d424d761a90190da40830dfe5eaa

See more details on using hashes here.

Provenance

The following attestation bundles were made for anyio_cysqlite-0.2.0-py3-none-any.whl:

Publisher: python-publish.yml on Vizonex/anyio-cysqlite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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