Skip to content
This repository has been archived by the owner on Jun 17, 2022. It is now read-only.

Latest commit

 

History

History
43 lines (34 loc) · 1.18 KB

README.md

File metadata and controls

43 lines (34 loc) · 1.18 KB

aiosqlite3

Travis Build Status codecov pypi

Basic Example

import asyncio
import aiosqlite3

async def test_example(loop):
    conn = await aiosqlite3.connect('sqlite.db', loop=loop)
    cur = await conn.cursor()
    await cur.execute("SELECT 42;")
    r = await cur.fetchall()
    print(r)
    await cur.close()
    await conn.close()

if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    loop.run_until_complete(test_example(loop))

or async with

import asyncio
import aiosqlite3

async def test_example(loop):
    async with aiosqlite3.connect('sqlite.db', loop=loop) as conn:
        async with conn.cursor() as cur:
            await cur.execute("SELECT 42;")
            r = await cur.fetchall()
            print(r)

if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    loop.run_until_complete(test_example(loop))