Skip to main content

a anyio and cysqlite library

Project description

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.1.0.tar.gz (9.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.1.0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for anyio_cysqlite-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5e29cde5a2fb2986706d68787e6717c6343d115c5fe05b3c2de4762282e56469
MD5 3eb98e80dcf2506696860849a20b768c
BLAKE2b-256 6b845cad09975fdb9c09949376d2bf31a975e1ab506cb11bdbefa9b93af46302

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for anyio_cysqlite-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fde35ad1183391b8cde9d6a04b16ea8e84557492638f5c954d25a872ab85852d
MD5 1fd2caa81a5dc263c7c3e1e1e9a21795
BLAKE2b-256 85db80add4dea4885fe0e6f7a73017ea06f74e572457c243f719f2cd24988280

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