A simple PostgreSQL to Python mapper.
Project description
halfORM
⚠️ 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/LoaderAPI. 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file half_orm-0.18.9.tar.gz.
File metadata
- Download URL: half_orm-0.18.9.tar.gz
- Upload date:
- Size: 60.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
34a63bfd2895631c96e46652ee71ac87753b582f51de5143af781b6ba4ef5026
|
|
| MD5 |
71b7ae549a9b54b4f4dd7140447d05c7
|
|
| BLAKE2b-256 |
11440d749222f89674d9b9052c87cd6194f0e722d50de9f5f705d002fdb064ea
|
File details
Details for the file half_orm-0.18.9-py3-none-any.whl.
File metadata
- Download URL: half_orm-0.18.9-py3-none-any.whl
- Upload date:
- Size: 57.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dfdf62a600e963b74ca43625a837db783b23ff885c7861e06ce87c88f383953d
|
|
| MD5 |
8e766e204ecf6726f569bb246313a6dc
|
|
| BLAKE2b-256 |
49b8effbb9b2564cbe4443240502bc01216826a10c612d956cfd7e4bfab8319b
|