Hojo - An Opinionated ORM on Top of SQL Alchemy
Hojo is a library that simplifies the usage of SQL Alchemy, providing an interface that is familiar to Django users. While it is not an exact replication of the Django ORM API, it strives to be reminiscent of it, making it easier for Django developers to work with SQL Alchemy.
Please note that this library is currently in Alpha version and is not yet ready for production use.
Installation
You can install Hojo using pip:
pip install hojo
Basic Usage
Here's a basic example of how to use Hojo:
# file: models.py
from hojo import automap, model
@model
class Soldier:
name: str
weapon: str
level: int
# Create the mappers automatically
automap()
# file: query.py
# Insert the hero into the 'soldiers' table
hero = Soldier.objects.create(name='Cloud Strife', weapon='Buster Sword', level=50)
# Insert the antagonist into the 'soldiers' table
antagonist = Soldier.objects.create(name='Sephiroth', weapon='Masamune', level=99)
# Retrieve a Soldier with the name 'Cloud' from the 'soldiers' table
soldier = Soldier.objects.filter(name='Cloud Strife')
# Retrieve a Soldier filtering by the weapon
soldier = Soldier.objects.filter(weapon__startswith='Buster')
# Retrieve a list of Soldiers filtering by level greater than 10
soldiers = Soldier.objects.filter(level__gt=10)
Schema usage
Hojo provides a BaseSchema class, that you can use with attrs @define and get some abstractions over it:
from hojo import schema
from enum import StrEnum
class MateriaType(StrEnum):
MAGIC = 'magic'
SUPPORT = 'support'
SUMMON = 'summon'
COMMAND = 'command'
@schema
class Materia:
name: str
materia_type: MateriaType
ifrit = Materia.load({'name': 'Ifrit', 'materia_type': 'summon'})
print(ifrit) # => Materia(name='Ifrit', materia_type=<MateriaType.SUMMON: 'summon'>)
print(ifrit.dump()) # => {'name': 'Ifrit', 'materia_type': 'summon'}
print(ifrit.dump(only=['name'])) # => {'name': 'Ifrit'}
print(ifrit.dump(exclude=['name'])) # => {'materia_type': 'summon'}
Metadata
Release files for hojo 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hojo-0.3.1.tar.gz | 9.2 kB | Without provenance | Details for hojo-0.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hojo-0.3.1-py3-none-any.whl | Python 3 | none | any | Details for hojo-0.3.1-py3-none-any.whl |
Total release size: 19.7 kB
Release files / hojo-0.3.1.tar.gz
| Download URL | hojo-0.3.1.tar.gz |
|---|---|
| Size | 9.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
85d16fd9858dde8e18231723e85182f1f8cfd2b7be3356758dbfdd05ea93a7d5
|
|
BLAKE2b-256 checksum How to use checksums |
a7e51fe1ee0a59f412347b525ffb7d7bc2446b34e56a9e26beced39bd6d05b21
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.6.1 CPython/3.9.13 Darwin/22.3.0
|
Release files / hojo-0.3.1-py3-none-any.whl
| Download URL | hojo-0.3.1-py3-none-any.whl |
|---|---|
| Size | 10.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9751285fcbd291336c1d059bbb4d3f7454d74685617da1cb3c2c20d5ad8bd291
|
|
BLAKE2b-256 checksum How to use checksums |
1b2b166ee2782dd1c8e1370b55a8a2c088bb97827f3be9bc97da63c6586c4b50
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.6.1 CPython/3.9.13 Darwin/22.3.0
|
Security for hojo 0.3.1
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.