Example #1
0
def _connect_pool(loop, finalizer, **kw):
    pool = loop.run_until_complete(aioodbc.create_pool(loop=loop, **kw))

    def fin():
        pool.close()
        loop.run_until_complete(pool.wait_closed())

    finalizer(fin)
    return pool
Example #2
0
async def test_example():
    dsn = 'Driver=SQLite;Database=sqlite.db'

    async with aioodbc.create_pool(dsn=dsn, loop=loop) as pool:
        async with pool.acquire() as conn:
            async with conn.cursor() as cur:
                await cur.execute('SELECT 42;')
                val = await cur.fetchone()
                print(val)
Example #3
0
    async def go():
        async with aioodbc.create_pool(dsn=dsn, loop=loop) as pool:
            async with pool.acquire() as conn:
                async with conn.cursor() as cur:
                    assert not pool.closed
                    assert not conn.closed
                    assert not cur.closed

                    await cur.execute('SELECT 1')
                    val = await cur.fetchone()
                    assert (1,) == tuple(val)

        assert pool.closed
        assert conn.closed
        assert cur.closed