Skip to main content

uofast-orm

Simple, fast ORM for U2 Unidata/UniVerse databases via uopy.

Install

pip install uofast-orm

Quick Start

import uopy
from uofast_orm import UopyModel

class Customer(UopyModel):
    _file_name = "CUSTOMERS"
    _field_names = ["NAME", "EMAIL", "PHONE", "ADDRESS"]
    _field_map = {
        "full_name": "NAME",
        "email_address": "EMAIL",
        "phone_number": "PHONE",
        "street_address": "ADDRESS",
    }

with uopy.connect(host="...", user="...", password="...", account="...") as session:
    # Create
    c = Customer(session)
    c.full_name = "Jane Smith"
    c.email_address = "jane@example.com"
    c.create("CUST001")

    # Read
    c = Customer(session, record_id="CUST001")
    print(c.full_name)

    # Update
    c.phone_number = "555-1234"
    c.update()

    # Query
    results = c.select('NAME = "Jane Smith"')

    # Delete
    c.delete()

Models

Subclass UopyModel and set class attributes:

Attribute Required Description
_file_name Yes U2 file name
_field_names Yes* List of DICT field names
_field_map No {"python_name": "DICT_NAME"} mapping
_enable_cache No Enable LRU cache (default: False)
_cache_max_size No Max cached records (default: 100)

* Can be omitted when _field_map is provided.

Named Fields with Alternative DICT

When multiple data files share a single DICT:

from uofast_orm import SmartFile, patch_uopy_file

# Option A: monkey-patch uopy.File globally (zero call-site changes)
patch_uopy_file()

# Option B: use SmartFile directly
with SmartFile("ORDERS") as f:
    rec = f.read_named_fields("ORD001", ["CUSTNO", "AMOUNT"],
                              dict_file="SHARED_DICT")
    f.write_named_fields("ORD001", {"AMOUNT": 999}, dict_file="SHARED_DICT")

Code Generator

Auto-generate model classes from U2 DICT definitions (requires Ollama):

uofast-generate CUSTOMERS \
  --host 192.168.1.10 --user admin --password secret \
  --account /u2/MYACCOUNT \
  --output customer_model.py

Falls back to template-based generation if Ollama is unavailable.

API Reference

UopyModel

Method Description
load() Load record from database
create(record_id) Create new record
update() Update existing record
delete() Delete record
save() Create or update (auto-detects)
get(field, default) Get field value (supports property or DB name)
set(field, value) Set field value (supports property or DB name)
to_dict(use_property_names) Export as dict
select(stmt, limit, offset) Run SELECT statement, return model list
read(record_id) Read single record, return model instance
read_many(ids, batch_size) Batch read, return model list
clear_cache() Clear LRU cache (classmethod)

Requirements

  • Python 3.8+
  • uopy (U2 Unidata/UniVerse client)
  • requests (for code generator Ollama calls)

License

MIT

Metadata

Release files for uofast-orm 1.1.0

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

Source distribution (sdist)

Source distribution for uofast-orm 1.1.0
File Size Uploaded Provenance Actions
uofast_orm-1.1.0.tar.gz 17.3 kB Without provenance Details for uofast_orm-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for uofast-orm 1.1.0
File Interpreter ABI Platform Actions
uofast_orm-1.1.0-py3-none-any.whl Python 3 none any Details for uofast_orm-1.1.0-py3-none-any.whl

Total release size: 34.5 kB

Release files / uofast_orm-1.1.0.tar.gz

Download URL uofast_orm-1.1.0.tar.gz
Size 17.3 kB
Tags Source
SHA-256 checksum
How to use checksums
25949e92efc60bdf8392145d72321318b649a942593e83955fa24cc9d8fe73aa
BLAKE2b-256 checksum
How to use checksums
383c404cf0a74caba6b30b3e8927defba3b964af6ab23e29f5fb0ef76a45f430
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.9

Release files / uofast_orm-1.1.0-py3-none-any.whl

Download URL uofast_orm-1.1.0-py3-none-any.whl
Size 17.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c6c0596c731d2d9b523c18300503beeffa12ee36d4cafad6ae3ce0a7e180b27f
BLAKE2b-256 checksum
How to use checksums
bf927ccad37dda4f97669c40b22febf78941f891dc0eb161acdb766285b970ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.9

Security for uofast-orm 1.1.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files No provenance

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