Skip to main content

PolyNOM — Polypheny Native Object Mapper

PolyNOM currently maps Python model instances to rows in relational tables in Polypheny. Use sessions to insert, query, update, and delete model instances in a transaction. PolyNOM can create missing tables from registered schemas and offers optional schema migration and statement logging.

Installation

You need Python 3.11 or later and a Polypheny server with a compatible Prism 2.x interface. PolyNOM uses the Python connector version >=2,<3. The package name on PyPI is polypheny-polynom, and the module name is polynom.

python -m pip install polypheny-polynom

To install the version from this repository, run python -m pip install . from the checkout.

Quick start

Start Polypheny with its plain Prism interface on port 20590. The example uses the default local credentials. For another server, pass its address, user, and password to Application. Choose one application UUID and reuse it across runs so PolyNOM can identify the application's schema snapshot.

from polynom.application import Application
from polynom.model.model import BaseModel
from polynom.schema.field import Field
from polynom.schema.polytypes import VarChar
from polynom.schema.schema import BaseSchema
from polynom.schema.schema_registry import polynom_schema
from polynom.session import Session


@polynom_schema
class ContactSchema(BaseSchema):
    namespace_name = "polynom_example"
    entity_name = "polynom_contacts"
    fields = [Field("name", VarChar(80), nullable=False)]


class Contact(BaseModel):
    schema = ContactSchema()

    def __init__(self, name, _entry_id=None):
        super().__init__(_entry_id)
        self.name = name


with Application("9cfe6791-0333-4689-9b77-37a83161fa93", ("127.0.0.1", 20590)) as app:
    with Session(app) as session:
        contact = Contact("Ada Lovelace")
        session.add(contact)
        contact_id = contact._entry_id
        session.commit()

    with Session(app) as session:
        saved = Contact.query(session).get(contact_id)
        print(saved.name)

Enable schema migration with Application(..., migrate=True) when you want PolyNOM to apply changes to existing tables. For Docker-managed startup, configure POLYPHENY_IMAGE_NAME with a compatible Prism 2.x image in polynom.config before opening an application with use_docker=True.

Development

Run these commands from the repository root. Start a disposable Polypheny instance for the integration tests, which create and delete test data. Set POLYNOM_TEST_HOST and POLYNOM_TEST_PORT to override the defaults of 127.0.0.1 and 20590.

python -m pip install -e '.[dev]'
python -m pytest

Run the tests that do not require a database with python -m pytest -m 'not integration'.

Further reading

Metadata

Release files for polypheny-polynom 0.4.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 polypheny-polynom 0.4.0
File Size Uploaded Provenance Actions
polypheny_polynom-0.4.0.tar.gz 35.9 kB Without provenance Details for polypheny_polynom-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for polypheny-polynom 0.4.0
File Interpreter ABI Platform Actions
polypheny_polynom-0.4.0-py3-none-any.whl Python 3 none any Details for polypheny_polynom-0.4.0-py3-none-any.whl

Total release size: 67.9 kB

Release files / polypheny_polynom-0.4.0.tar.gz

Download URL polypheny_polynom-0.4.0.tar.gz
Size 35.9 kB
Tags Source
SHA-256 checksum
How to use checksums
450734dba5584334fd18660851d4c95047fd45e5d977abf4608eecd74853accf
BLAKE2b-256 checksum
How to use checksums
8d922beaa643d787d6642896c68676bcc55a4668ab244dddbea5ca520dcd22b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / polypheny_polynom-0.4.0-py3-none-any.whl

Download URL polypheny_polynom-0.4.0-py3-none-any.whl
Size 32.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6fbf1f857316f2e9ffefe8611b282a2c3980642bb8632e1be3794d3edb5e5913
BLAKE2b-256 checksum
How to use checksums
b40fef8c7c4d027b495b8696411d3b6e11cbbb03f1426b2677abc3b06e159f6d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for polypheny-polynom 0.4.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.

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