Skip to content

Oracle🔗

Supported drivers:

dbapi default driver connection class
oracledb 👍 oracle+oracledb oracledb.Connection

oracledb🔗

oracledb is the default dbapi driver for Oracle in pydapper.

Installation🔗

pip install pydapper[oracledb]
poetry add pydapper -E oracledb

DSN format🔗

dsn = f"oracle+oracledb://{user}:{password}@{host}:{port}/{servicename}"
dsn = "oracle+oracledb://myuser:mypassword@localhost:1521/myservicename"
dsn = "oracle://myuser:mypassword@localhost:1521/myservicename"

Note

You connect to oracledb in pydapper using service names

Example - connect🔗

Exiting the with block closes the connection and rolls back any uncommitted work — see Transactions below.

import pydapper

with pydapper.connect("oracle+oracledb://pydapper:pydapper@localhost:1522/pydapper") as commands:
    print(type(commands))
    # <class 'pydapper.oracle.oracledb.OracledbCommands'>

    print(type(commands.connection))
    # <class 'oracledb.Connection'>

    with commands.cursor() as raw_cursor:
        print(type(raw_cursor))
        # <class 'oracledb.Cursor'>

Example - using🔗

Use pydapper with a oracledb connection pool.

from oracledb import create_pool

import pydapper

my_pool = create_pool(user="pydapper", password="pydapper", dsn="localhost:1522/pydapper")


commands = pydapper.using(my_pool.acquire())
print(type(commands))
# <class 'pydapper.oracle.oracledb.OracledbCommands'>

print(type(commands.connection))
# <class 'oracledb.Connection'>

my_pool.release(commands.connection)

Transactions🔗

oracledb connects with autocommit off (connection.autocommit is a read-write property if you want per-statement commits). Exiting with pydapper.connect(...) delegates to the driver's context manager, which rolls back uncommitted work and closes the connection — it never commits. Commit explicitly (commands.commit()) or scope the work in a transaction() block, which commits on clean exit.

One server-side caveat: Oracle implicitly commits DDL statements, and that implicit commit also commits any uncommitted DML issued earlier on the same connection.

See Transactions and Context manager semantics for the cross-driver picture.