Socket
Socket
Sign inDemoInstall

ormic

Package Overview
Dependencies
1
Maintainers
1
Alerts
File Explorer

Install Socket

Protect your apps from supply chain attacks

Install

ormic

A simple, asynchronous python ORM for SQLite databases

    1.0.0

Maintainers
1

Readme

ormic

A simple, asynchronous python ORM for SQLite databases

Installation

# stable
$ pip install ormic

# unstable
$ pip install git+https://github.com/Dorukyum/ormic

Quickstart

from ormic import Database, Model

db = Database()

# create a model
@db.model
class Point(Model):
    name: str
    x: int
    y: int = 5  # default value

# connect to a database
await db.connect("database.db")

Database Actions

# create an object
point = Point(name="A", x=5, y=10)
await point.save()

# fetch objects from the database
point_named_A: Point | None                = await Point.fetch(name="A")
list_of_points_named_A: list[Point] | None = await Point.fetch_all(name="A")

# update an object
await point.update(y=15)
# or
point.y = 15
await point.update()

# delete an object
await point.delete()

Caching

# turn caching on
# setting limit to 20 will only cache the last fetched 20 objects
# this parameter defaults to None, caching all fetched objects
database.set_caching(on=True, limit=20)

# get the object from the cache
# will fetch from the database if no matches found
point_named_A = await Point.get_or_fetch(name="A")

Keywords

FAQs


Did you know?

Socket installs a GitHub app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc