Skip to main content

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

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.config import DbConfig
from fresh_orm.model import BaseModel
from fresh_orm.repository import 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fresh_orm-0.0.1.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fresh_orm-0.0.1-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file fresh_orm-0.0.1.tar.gz.

File metadata

  • Download URL: fresh_orm-0.0.1.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.16

File hashes

Hashes for fresh_orm-0.0.1.tar.gz
Algorithm Hash digest
SHA256 666613c094c51055f5c01c773c934e90b89179928d16f1fa228f8e7661206b83
MD5 b273d27c06ff7a69ff8899fca0ab2b7f
BLAKE2b-256 fae75d9fcb34535b2c8e691018f58eb0cad0ece14d0c4c457be0311b6d36681b

See more details on using hashes here.

File details

Details for the file fresh_orm-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: fresh_orm-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.16

File hashes

Hashes for fresh_orm-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 92ebc8ba775248b76f60778c58a17a769db43c53716b84b0208f20aa2638456f
MD5 a92842d793b50f1de9a432592463049c
BLAKE2b-256 67a49379c3c1ab4fdec663911075b31aaff6dd708acea1cb5344f53997a9a75f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page