Skip to main content

ODBC driver for asyncio.

Project description

aioodbc is Python module that makes possible accessing ODBC databases with asyncio. It is rely on awesome pyodbc library, preserve same look and feel.

Basic Example

aioodbc based on pyodbc , and provides same api, you just need to use yield from conn.f() or await conn.f() instead of just call conn.f() for every method.

Properties are unchanged, so conn.prop is correct as well as conn.prop = val.

import asyncio
import aioodbc

loop = asyncio.get_event_loop()

def test_example():
    dsn = 'Driver=SQLite;Database=sqlite.db'
    conn = yield from aioodbc.connect(dsn=dsn, loop=loop)

    cur = yield from conn.cursor()
    yield from cur.execute("SELECT 42;")
    r = yield from cur.fetchall()
    yield from cur.close()
    yield from conn.close()


Connection Pool

Connection pooling ported from aiopg and rely on PEP492 features:

import asyncio
import aioodbc

loop = asyncio.get_event_loop()

async def test_pool():
    dsn = 'Driver=SQLite;Database=sqlite.db'
    pool = await aioodbc.create_pool(dsn=dsn, loop=loop)

    async with (await pool) as conn:
        cur = await conn.cursor()
        await cur.execute("SELECT 42;")
        r = await cur.fetchall()
        await cur.close()
        await conn.close()
    await pool.wait_closed()



pip3 install git+

In Linux environment pyodbc (hence aioodbc) requires unixODBC library. You can use standard one from your distro like:

$ sudo apt-get install unixodbc
$ sudo apt-get install unixodbc-dev

Other SQL Drivers

  • aiopg - asyncio client for PostgreSQL

  • aiomysql - asyncio client form MySQL



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

aioodbc-0.0.1.tar.gz (17.8 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page