Skip to main content

halfORM

PyPI version Python versions PostgreSQL versions License Tests Coverage Downloads

⚠️ BREAKING CHANGE in v0.18 — psycopg2 → psycopg 3

halfORM 0.18 drops psycopg2 and requires psycopg 3.

pip uninstall psycopg2-binary
pip install "psycopg[binary]"

If you use custom psycopg2 adapters in your own code, rewrite them with the psycopg 3 Dumper/Loader API. See the full migration notes in CHANGELOG.md.

psycopg2 users: the 0.17.x branch is maintained for psycopg2 and receives bug fixes.

halfORM is a database-first ORM for PostgreSQL. You write the schema in SQL; halfORM introspects it at runtime and gives you Python objects to work with your data. No migrations, no code generation.

The central idea: a Relation object is a predicate. It describes the logical condition that rows must satisfy to belong to the relation. Its extension — the set of rows that currently satisfy the predicate in the database — is what you read, update, or delete.

Install

pip install half_orm

Configure

# ~/.half_orm/blog
[database]
name = blog
user = alice
password = secret
host = localhost

Usage

from half_orm.model import Model

blog = Model('blog')
Post   = blog.get_relation_class('blog.post')
Author = blog.get_relation_class('blog.author')

# Insert
alice = Author(
    first_name='Alice', last_name='Martin', email='alice@example.com'
).ho_insert()

# Query — Author(last_name='Martin') is the predicate "is an author named Martin"
for row in Author(last_name='Martin').ho_select('id', 'email'):
    print(row)

# Update a singleton (predicate identifies exactly one row)
Author(id=alice['id']).ho_assert_is_singleton().ho_update(email='alice@newdomain.com')

# Delete
Author(id=alice['id']).ho_assert_is_singleton().ho_delete()

Documentation

License

halfORM is licensed under the GPL-3.0 license.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

half_orm-0.18.13.tar.gz (65.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

half_orm-0.18.13-py3-none-any.whl (62.2 kB view details)

Uploaded Python 3

File details

Details for the file half_orm-0.18.13.tar.gz.

File metadata

  • Download URL: half_orm-0.18.13.tar.gz
  • Upload date:
  • Size: 65.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.19

File hashes

Hashes for half_orm-0.18.13.tar.gz
Algorithm Hash digest
SHA256 e660e163ea04bc5575feea8fca18de4f1afbfac15ec2a44badaeeb38f2b1ab45
MD5 334702c3bc880233247a996a14a11eca
BLAKE2b-256 ae079eecc4a74ec15cf6677c0e1e41dde6161538f9f851b095d1500d1127dc35

See more details on using hashes here.

File details

Details for the file half_orm-0.18.13-py3-none-any.whl.

File metadata

  • Download URL: half_orm-0.18.13-py3-none-any.whl
  • Upload date:
  • Size: 62.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.19

File hashes

Hashes for half_orm-0.18.13-py3-none-any.whl
Algorithm Hash digest
SHA256 0c3537856bd839882aed7b9d7a7d0faa5ce15ff2aedfc712979f6c04b9a5d24e
MD5 63f8d65f99609d88019d2aaae3ebb81e
BLAKE2b-256 e7a70e4e11c30e98e0e60ee2f2c24fe875f1ad79e3d4cf1bb8d487a194a2805b

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.18.13 This release

2 files

0.18.12

2 files

0.18.11

2 files

0.18.10

2 files

0.18.9

2 files

0.18.8

2 files

0.18.7

2 files

0.18.6

2 files

0.18.5

2 files

0.18.3

2 files

0.18.2

2 files

0.18.1

2 files

0.18.0

2 files

0.17.11

2 files

0.17.10

2 files

0.17.9

2 files

0.17.8

2 files

0.17.7

2 files

0.17.6

2 files

0.17.5

2 files

0.17.4

2 files

0.17.3

2 files

0.17.2

2 files

0.17.1

2 files

0.17.0

2 files

0.16.4

2 files

0.16.3

2 files

0.16.2

2 files

0.16.1

2 files

0.16.0

2 files

0.15.1

2 files

0.15.0

2 files

0.14.0

2 files

0.13.10

2 files

0.13.9

2 files

0.13.8

2 files

0.13.7

2 files

0.13.6

2 files

0.13.5

2 files

0.13.4

2 files

0.13.3

2 files

0.13.2

2 files

0.13.1

2 files

0.13.0

2 files

0.12.1

2 files

0.12.0

2 files

0.11.1

2 files

0.11.0

2 files

0.10.5

2 files

0.10.4

2 files

0.10.3

2 files

0.10.2

2 files

0.10.1

2 files

0.10.0

2 files

0.9.12

2 files

0.9.11

2 files

0.9.10

2 files

0.9.9

2 files

0.9.8

2 files

0.9.7

2 files

0.9.6

2 files

0.9.5

2 files

0.9.4

2 files

0.9.3

2 files

0.9.2

2 files

0.9.1

2 files

0.9.0

2 files

0.8.0

2 files

0.7.5

2 files

0.7.4

2 files

0.7.3

2 files

0.7.2

2 files

0.7.1

2 files

0.7.0

2 files

0.6.4

2 files

0.6.3

2 files

0.6.1

2 files

0.6.0

2 files

0.5.14

2 files

0.5.13

2 files

0.5.12

2 files

0.5.11

2 files

0.5.10

2 files

0.5.9

2 files

0.5.8

2 files

0.5.7

2 files

0.5.6

2 files

0.5.5

2 files

0.5.4

2 files

0.5.3

2 files

0.5.2

2 files

0.5.1

2 files

0.5.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page