Metadata-Version: 2.4
Name: sqlitepool
Version: 0.0.0
Summary: A thread-pooled sqlite3 for asyncio.
Author-email: Anggit Arfanto <contact@anggit.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/nggit/sqlitepool
Project-URL: Source, https://github.com/nggit/sqlitepool
Project-URL: Funding, https://github.com/sponsors/nggit
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# SQLitePool
A thread-pooled [sqlite3](https://docs.python.org/3/library/sqlite3.html) 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
```python
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
