Skip to main content

Ormlet is a lightweight, minimal ORM designed to give you just enough structure and flexibility to build SQL queries.

Project description

Ormlet

Ormlet is a lightweight, minimal ORM designed to give you just enough structure and flexibility to build SQL queries.


The key features are:

  • Declarative column definitions (IntegerField, TextField, etc.)
  • Auto SQL generation for SELECT, INSERT, UPDATE, DELETE
  • Fluent and chainable QueryBuilder
  • Logical operators: AND, OR, multiple WHERE support

Installation

Create and activate a virtual environment and then install Ormlet:

$ pip install ormlet
---> 100%
Successfully installed ormlet

Example

Models

from ormlet import Model, column


class User(Model):
    __table__ = "users"

    id = column.IntegerField(primary_key=True, autoincrement=True)
    name = column.VarCharField(max_length=50)
    age = column.IntegerField()

Database Manager

from ormlet import DatabaseManager

db = DatabaseManager("test.db")
db.register_tables([User])

Queries

from ormlet import insert, select, update, delete

insert(User).values(id=1, name="Alice", age=30).execute(connection)
select(User).where(User.name == "Bob").execute(connection)
update(User).set(age=41).where(User.name == "Charlie").execute(connection)
delete(User).where(User.name == "Dan").execute(connection)

Quick Example

from ormlet import DatabaseManager, Model, column

class User(Model):
    __table__ = "users"

    id = column.IntegerField(primary_key=True)
    name = column.VarCharField(max_length=50)
    age = column.IntegerField()

db = DatabaseManager("test.db")
db.register_tables([User])

with db.connect() as conn:
    insert(User).values(id=1, name="Alice", age=30).execute(conn)
    select(User).where(User.name == "Alice").execute(conn)
    update(User).set(age=41).where(User.name == "Alice").execute(conn)
    delete(User).where(User.id== 1).execute(conn)

Dependencies

Ormlet uses no external dependencies it works with just standard Python.

License

This project is licensed under the terms of the MIT license.

Contributing

Feel free to open issues, suggest features, or submit PRs.

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

ormlet-0.1.0.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

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

ormlet-0.1.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file ormlet-0.1.0.tar.gz.

File metadata

  • Download URL: ormlet-0.1.0.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for ormlet-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0b3e2eecb4fff8d56acde4047eab6a960e2d239be402721e761417286bad36de
MD5 277abebf6260e99c0c8740b438656c73
BLAKE2b-256 ac909ead8659878a076cf638c669b0bcb2c8a329e36270f79f1b1d835e539600

See more details on using hashes here.

File details

Details for the file ormlet-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ormlet-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for ormlet-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1fbb0d811073584bc94e6f954208160639ff15bc275a8f7a92a054fab2c962b0
MD5 df5598854e50b8c59e5da37795c241e9
BLAKE2b-256 ebb244c282c32023445a5c614f86f2e9950e954a68e44fb482ca0dd1ee1cf98e

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