fresh_orm
Fresh ORM
A lightweight SQLite Object-Relational Mapping (ORM) library for Python, designed to simplify database interactions and provide an intuitive interface for managing SQLite tables and relationships.
Features
-
Foreign Key Support
- Foreign keys are mapped to integers (
INTEGERtype in SQLite), enabling relationships between tables.
- Foreign keys are mapped to integers (
-
Table Creation
- Automatically generates SQLite tables based on Python model definitions.
-
CRUD Operations
create: Insert new records into a table.update: Update specific fields of existing records.by_id: Retrieve a single record by its primary key.all: Fetch all records from a table.filter: Query records based on specific conditions with support for logical operations.
-
Seamless Mapping
- Define models as Python classes and map them directly to SQLite tables without boilerplate code.
Example Usage
from dataclasses import dataclass
from fresh_orm import DbConfig, BaseModel, BaseRepository
@dataclass
class DummyType(BaseModel):
name: str = None
@dataclass
class Dummy(BaseModel):
name: str = None
type: DummyType = None
class DummyTypeRepo(BaseRepository[DummyType]):
model = DummyType
class DummyRepo(BaseRepository[Dummy]):
model = Dummy
DbConfig.init_tables([Dummy, DummyType])
dummy_type = DummyTypeRepo.create(DummyType(name='Test Dummy Type'))
dummy: Dummy = DummyRepo.create(Dummy(name='Test Dummy', type=dummy_type))
dummy_from_db: Dummy = DummyRepo.by_id(dummy.id)
assert dummy_from_db.name == dummy.name
assert dummy_from_db.type == dummy.type.id
Metadata
Release files for fresh-orm 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| fresh_orm-0.0.2.tar.gz | 4.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fresh_orm-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.5 kB
Release files / fresh_orm-0.0.2.tar.gz
| Download URL | fresh_orm-0.0.2.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5792459edbe13b21296e77630f9054f47080a658d8938c6bc36257046d757084
|
|
BLAKE2b-256 checksum How to use checksums |
2a6e730df05ebe5364f485e4ddedfd610fd589aad3428e0e826bee664f346187
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.16
|
Release files / fresh_orm-0.0.2-py3-none-any.whl
| Download URL | fresh_orm-0.0.2-py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c8e81f7f936411ebf557481b53db9dbd78d66b3f93221ad11e0c8d5d51e7803a
|
|
BLAKE2b-256 checksum How to use checksums |
5a5dd71a377ddb313c97e6cf04ff5661744eff664eedbaee1246f790b9a50bf2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.16
|