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.
Project description
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
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 fresh_orm-0.0.2.tar.gz.
File metadata
- Download URL: fresh_orm-0.0.2.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5792459edbe13b21296e77630f9054f47080a658d8938c6bc36257046d757084
|
|
| MD5 |
b6a318f52fa25619dd3099c8b27161c2
|
|
| BLAKE2b-256 |
2a6e730df05ebe5364f485e4ddedfd610fd589aad3428e0e826bee664f346187
|
File details
Details for the file fresh_orm-0.0.2-py3-none-any.whl.
File metadata
- Download URL: fresh_orm-0.0.2-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c8e81f7f936411ebf557481b53db9dbd78d66b3f93221ad11e0c8d5d51e7803a
|
|
| MD5 |
ab8ee7dddc3ec50340c77adad54fe37d
|
|
| BLAKE2b-256 |
5a5dd71a377ddb313c97e6cf04ff5661744eff664eedbaee1246f790b9a50bf2
|