Skip to main content

Purpose

An asynchronous way to connect to an sqlite3 database. Normally, this would block the asyncio event loop and slow down the execution speed of the script. This is because asyncio isn’t meant for I/O bound tasks. threading is more efficient for that, which is exactly why this module uses it under the hood.

Features

  • A similar syntax to the sqlite3 module in the Standard library

  • Has asyncio idioms such as async for, await, and async with

  • Provides all features of the built-in sqlite3 module

Installation

Installing asqlite3 should be done through PIP:

$ pip install asqlite3

Make sure you have Python version 3.6+ before installing!

Contributing

Contributions are always encouraged and open.

Examples

import asyncio

import asqlite3

conn = asqlite3.connect(':memory:')

async def connection():
    async with conn:
        await conn.execute("CREATE TABLE table (plate INT)")
        await conn.execute("INSERT INTO table VALUES (5)")
    # connection is automatically closed

loop = asyncio.get_event_loop()
loop.run_until_complete(connection())
import asyncio

import asqlite3

conn = asqlite3.connect(':memory:')

async def cursor():
    cur = await conn.cursor()
    rows = [i async for i in cur]
    return rows

loop = asyncio.get_event_loop()
loop.run_until_complete(cursor())

License

asqlite is currently under the MIT license.

Release files for asqlite3 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for asqlite3 0.0.1
File Size Uploaded
asqlite3-0.0.1.tar.gz 5.8 kB Details

Release files / asqlite3-0.0.1.tar.gz

Download URL asqlite3-0.0.1.tar.gz
Size 5.8 kB
Tags Source
SHA-256 checksum
How to use checksums
569b26c1f69f4728434a44aeeb65bfef54dd2c605efc0f80baad94c41dfa63a0
BLAKE2b-256 checksum
How to use checksums
f176ace956ceb49f3f30b7211d0689df2b1dbace5f0f7df60c50532bbbe8b0a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.2

Release history Release notifications | RSS feed

This release

0.0.1 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page