Skip to main content

fresh_orm

Unit-Tests
Published Python Package

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

  1. Foreign Key Support

    • Foreign keys are mapped to integers (INTEGER type in SQLite), enabling relationships between tables.
  2. Table Creation

    • Automatically generates SQLite tables based on Python model definitions.
  3. 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.
  4. 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)

Source distribution for fresh-orm 0.0.2
File Size Uploaded
fresh_orm-0.0.2.tar.gz 4.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fresh-orm 0.0.2
File Interpreter ABI Platform
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

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page