Note: This is a backend implementation for rhosocial-activerecord. It cannot be used standalone.
| 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 |
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()- 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
pip install rhosocial-activerecord-oraclefrom 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?"
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 INTOQuery historical state without restore:
# As of a past timestamp
past_users = User.query().where(
"id = ? AS OF TIMESTAMP (SYSTIMESTAMP - INTERVAL '1' HOUR)",
(1,),
).all()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()Native materialized view support:
# Refreshable MV DDL
User.query().where(
"MATERIALIZED VIEW mv_users REFRESH FAST ON COMMIT"
).all()- Python: 3.9+ (including 3.13t/3.14t free-threaded builds)
- Core:
rhosocial-activerecord>=1.0.0 - Driver:
oracledb>=3.0.0
| 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.
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- "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"
Feed the documentation files in docs/ to your preferred LLM for context-aware assistance.
β οΈ CRITICAL: Tests MUST run serially. Do NOT usepytest -n autoor 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.
- Getting Started β Installation and configuration
- Oracle Features β Oracle-specific capabilities
- Type Adapters β Data type handling
- Transaction Support β Transaction management
| Feature | Oracle | PostgreSQL | SQLite |
|---|---|---|---|
| RETURNING | β RETURNING INTO | β RETURNING | β RETURNING |
| Flashback | β | β | β |
| Hierarchical Queries | β CONNECT BY | ||
| Materialized Views | β | β | β |
| Arrays | β Native | β |
π‘ AI Prompt: "When should I choose Oracle over PostgreSQL for my project?"
We welcome contributions! See CONTRIBUTING.md for guidelines.
Apache License 2.0 β Copyright Β© 2026 vistart
Built with β€οΈ by the rhosocial team
GitHub Β· Documentation Β· PyPI