Skip to main content

A thread-pooled sqlite3 for asyncio.

Project description

SQLitePool

A thread-pooled sqlite3 for asyncio.

Behavior

  • stmt.execute() return bool instead of a cursor object:
  • True if the query succeeds, or False otherwise
  • Empty results on INSERT, UPDATE, DELETE, and SELECT are considered as False

Usage

import asyncio

from sqlitepool import ConnectionPool


async def main():
    pool = ConnectionPool('example.db', size=5)
    await pool.start()

    try:
        stmt = pool.prepare(
            'CREATE TABLE IF NOT EXISTS users ('
            '  id INTEGER PRIMARY KEY,'
            '  name TEXT NOT NULL,'
            '  age INTEGER NOT NULL'
            ');'
        )
        await stmt.execute()

        stmt = pool.prepare('INSERT INTO users (name, age) VALUES (?, ?)')
        await stmt.execute(['Alice', 30])

        stmt = pool.prepare('SELECT * FROM users LIMIT 10')
        await stmt.execute()
        row = await stmt.fetch()

        while row:
            print('*', row['name'], row['age'])
            row = await stmt.fetch()
    finally:
        await pool.shutdown()


if __name__ == '__main__':
    asyncio.run(main())

Install

python3 -m pip install --upgrade sqlitepool

License

MIT License

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

sqlitepool-0.0.0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

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

sqlitepool-0.0.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file sqlitepool-0.0.0.tar.gz.

File metadata

  • Download URL: sqlitepool-0.0.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for sqlitepool-0.0.0.tar.gz
Algorithm Hash digest
SHA256 6dc79eb16b9a3476ba04a5fcb2ca07c77a1fa89853f8d1dde881c21fb2e1ee14
MD5 f690f0153aa386a9e3b5abff0c9dc5e9
BLAKE2b-256 5440e1d35356229e5dab9206011eb493d7b5e952816f7d71da1f4b6bf11b761e

See more details on using hashes here.

File details

Details for the file sqlitepool-0.0.0-py3-none-any.whl.

File metadata

  • Download URL: sqlitepool-0.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for sqlitepool-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8bccee860890b223c02f3307420b882cb13fae696a3e35a63d6d0f635508496b
MD5 2b7b2fd9909bec17c20a448ebb9a0dc6
BLAKE2b-256 62484b3f782b712127fe13716da4e4f7a64646707b9d67a55010e76c2a8f91a2

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