Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

rhosocial-activerecord-oracle ($\rho_{\mathbf{AR}\text{-oracle}}$)

PyPI version Python Tests Coverage Status Apache 2.0 License Powered by vistart

rhosocial ActiveRecord Logo

Oracle Backend for rhosocial-activerecord

Enterprise PL/SQL Support · Flashback & Spatial · Sync & Async

Note: This is a backend implementation for rhosocial-activerecord. It cannot be used standalone.

Why This Backend?

1. Oracle-Specific Optimizations

Feature This Backend Generic Solutions
RETURNING Native RETURNING ... INTO Manual SELECT-after-write
Flashback AS OF TIMESTAMP, FLASHBACK TABLE Point-in-time recovery tooling
Materialized Views Native MV support Application-level caches
Spatial SDO_GEOMETRY External GIS systems
Hierarchical Queries CONNECT BY Application-level recursion

2. True Sync-Async Parity

Same API surface for both sync and async operations:

# Sync
users = User.query().where(User.c.age >= 18).all()

# Async - just add await
users = await User.query().where(User.c.age >= 18).all()

3. Built for Production

  • Connection pooling with configurable pool sizes
  • Transaction support with proper isolation levels
  • Error mapping from Oracle error codes to Python exceptions
  • Type adapters for Oracle-specific data types

Quick Start

Installation

pip install rhosocial-activerecord-oracle

Basic Usage

from rhosocial.activerecord.model import ActiveRecord
from rhosocial.activerecord.backend.impl.oracle import OracleBackend
from rhosocial.activerecord.backend.impl.oracle.config import OracleConnectionConfig
from typing import Optional

class User(ActiveRecord):
    __table_name__ = "users"
    id: Optional[int] = None
    name: str
    email: str

# Configure
config = OracleConnectionConfig(
    host="localhost",
    port=1521,
    database="ORCLPDB1",
    username="system",
    password="YourPassword"
)
User.configure(config, OracleBackend)

# Use
user = User(name="Alice", email="alice@example.com")
user.save()

# Query with parameter binding
results = User.query().where("email = ?", ("alice@example.com",)).all()

💡 AI Prompt: "How do I configure connection pooling for Oracle?"

Oracle-Specific Features

RETURNING INTO

Retrieve inserted or updated rows in a single round-trip:

# INSERT with RETURNING
user = User(name="Alice", email="alice@example.com")
user.save()
print(user.id)  # Populated automatically via RETURNING INTO

Flashback Queries

Query historical state without restore:

# As of a past timestamp
past_users = User.query().where(
    "id = ? AS OF TIMESTAMP (SYSTIMESTAMP - INTERVAL '1' HOUR)",
    (1,),
).all()

Hierarchical Queries

Oracle's CONNECT BY for tree-structured data:

# Org hierarchy traversal
Employee.query().where(
    "START WITH manager_id IS NULL CONNECT BY PRIOR emp_id = manager_id"
).all()

Materialized Views

Native materialized view support:

# Refreshable MV DDL
User.query().where(
    "MATERIALIZED VIEW mv_users REFRESH FAST ON COMMIT"
).all()

Requirements

  • Python: 3.9+ (including 3.13t/3.14t free-threaded builds)
  • Core: rhosocial-activerecord>=1.0.0
  • Driver: oracledb>=3.0.0

Oracle Version Compatibility

Feature Min Version Notes
Basic operations 18c+ Core functionality
JSON 18c+ JSON data type, JSON_TABLE
RETURNING INTO 8.0+ DML returning
Flashback queries 9.0+ AS OF TIMESTAMP
Hierarchical queries 8.0+ CONNECT BY
Materialized views 8.0+ MV refresh strategies
Sequences 8.0+ CREATE SEQUENCE
Spatial 8.1+ SDO_GEOMETRY
PIVOT 11.2+ Row-to-column transforms
Identity columns 12.1+ GENERATED AS IDENTITY
PL/SQL procedures 8.0+ Stored procedures
Vector search 23ai+ AI Vector Search

Recommended: Oracle 18c+ for optimal feature support.

Get Started with AI Code Agents

This project supports AI-assisted development. Clone and open in your preferred tool:

git clone https://github.com/rhosocial/python-activerecord-oracle.git
cd python-activerecord-oracle

Example AI Prompts

  • "How do I configure connection pooling for Oracle?"
  • "Show me how to use flashback queries"
  • "How do I use RETURNING INTO with INSERT?"
  • "Create a model with a hierarchical query"

For Any LLM

Feed the documentation files in docs/ to your preferred LLM for context-aware assistance.

Testing

⚠️ CRITICAL: Tests MUST run serially. Do NOT use pytest -n auto or parallel execution.

# Run all tests
PYTHONPATH=src pytest tests/

# Run specific feature tests
PYTHONPATH=src pytest tests/rhosocial/activerecord_oracle_test/feature/basic/
PYTHONPATH=src pytest tests/rhosocial/activerecord_oracle_test/feature/query/

See the Testing Documentation for details.

Documentation

Comparison with Other Backends

Feature Oracle PostgreSQL SQLite
RETURNING ✅ RETURNING INTO ✅ RETURNING ✅ RETURNING
Flashback ✅ ❌ ❌
Hierarchical Queries ✅ CONNECT BY ⚠️ WITH RECURSIVE ⚠️ WITH RECURSIVE
Materialized Views ✅ ✅ ❌
Arrays ⚠️ VARRAY ✅ Native ❌

💡 AI Prompt: "When should I choose Oracle over PostgreSQL for my project?"

Contributing

We welcome contributions! See CONTRIBUTING.md for guidelines.

License

Apache License 2.0 — Copyright © 2026 vistart


Built with ❤️ by the rhosocial team

GitHub · Documentation · PyPI

Metadata

Release files for rhosocial-activerecord-oracle 1.0.0.dev2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rhosocial-activerecord-oracle 1.0.0.dev2
File Size Uploaded
rhosocial_activerecord_oracle-1.0.0.dev2.tar.gz 187.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for rhosocial-activerecord-oracle 1.0.0.dev2
File Interpreter ABI Platform
rhosocial_activerecord_oracle-1.0.0.dev2-py3-none-any.whl Python 3 none any Details

Total release size: 453.5 kB

Release files / rhosocial_activerecord_oracle-1.0.0.dev2.tar.gz

Download URL rhosocial_activerecord_oracle-1.0.0.dev2.tar.gz
Size 187.3 kB
Tags Source
SHA-256 checksum
How to use checksums
893debbc9e681dacf41e5a6d4c9d6042b1e90f23803471916b93a845136e25db
BLAKE2b-256 checksum
How to use checksums
f1b964b71f201a9e96b6248e638b6f7e14858a9f180d001be70b865c38a36fa3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 15, 2026.

Transparency log

Release files / rhosocial_activerecord_oracle-1.0.0.dev2-py3-none-any.whl

Download URL rhosocial_activerecord_oracle-1.0.0.dev2-py3-none-any.whl
Size 266.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
91995cb11e83947fb342f67fd227c7e6b0039cd05e394b209ac63136e4c0a01b
BLAKE2b-256 checksum
How to use checksums
173431069b370b55f05cdae1f262652747c547fa1b3dd2ec9d77bc554ce3ea3b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 15, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.0.dev2 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page