aiogoldilocks

aiogoldilocks

aiogoldilocks is an asynchronous Python driver for GOLDILOCKS.

It is based on pygoldilocks and modeled after the aioodbc architecture, providing a reliable and efficient asyncio-based asynchronous interface.

Key Features

Example

import asyncio

import aiogoldilocks


async def test_example():
    dsn = "DSN=GOLDILOCKS;UID=test;PWD=test"
    conn = await aiogoldilocks.connect(dsn=dsn)

    cur = await conn.cursor()
    await cur.execute("SELECT 42 AS AGE FROM DUAL")
    rows = await cur.fetchall()
    print(rows)
    print(rows[0])
    print(rows[0].AGE)
    await cur.close()
    await conn.close()


asyncio.run(test_example())

Connection Pool

import asyncio

import aiogoldilocks


async def test_pool():
    dsn = "DSN=GOLDILOCKS;UID=test;PWD=test"
    pool = await aiogoldilocks.create_pool(dsn=dsn)

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


asyncio.run(test_pool())

Context Manager

import asyncio

import aiogoldilocks


async def test_example():
    dsn = "DSN=GOLDILOCKS;UID=test;PWD=test"

    async with aiogoldilocks.create_pool(dsn=dsn) as pool:
        async with pool.acquire() as conn:
            async with conn.cursor() as cur:
                await cur.execute("SELECT 42 AS AGE FROM DUAL")
                val = await cur.fetchone()
                print(val)
                print(val.AGE)


asyncio.run(test_example())

Installation

Install it under the $GOLDILOCKS_HOME/app_dev/aiogoldilocks directory as follows.

pip install .

Before installation, the GOLDILOCKS driver must already be installed, and either a DSN or a connection string must be configured in advance.

Requirements