Skip to main content

ORM Async for Python

Project description

DuckORM

The Duck-ORM package is an asynchronous ORM for Python, with support for Postgres and SQLite. ORM is built with:

Requirements: Python 3.8+

Duck-ORM is still under development.

Installation

$ pip install duck-orm

!!! note Don't forget to install databases before installing duck-orm.

Quickstart

For this example we will create a connection to the SQLite database and create a model.

$ pip install databases[sqlite]
$ pip install ipython

Note that we want to use ipython here, because it supports using await expressions directly from the console.

Creating the connection to the SQLite database:

from databases import Database
from duck_orm.model import Model

db = Database('sqlite:///example.db')
await db.connect()

Defining a model:

from duck_orm.sql import fields as Field

class Person(Model):
    __tablename__ = 'persons'
    __db__ = db

    id: int = Field.Integer(primary_key=True, auto_increment=True)
    first_name: str = Field.String(unique=True)
    last_name: str = Field.String(not_null=True)
    age: int = Field.BigInteger(min_value=18)

# Table creation in the database.
await Person.create()
  • The __tablename__ attribute is used to define the table's name in the database.
  • The __db__ attribute is the instance of the database connection.
  • And then the definition of the fields, their types and restrictions.
  • And finally, the table creation in the database.

Author

License

DuckORM is built as an open-source tool and remains completely free(MIT license).

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

duck_orm-1.0.2.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

duck_orm-1.0.2-py3-none-any.whl (15.1 kB view details)

Uploaded Python 3

File details

Details for the file duck_orm-1.0.2.tar.gz.

File metadata

  • Download URL: duck_orm-1.0.2.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.9.16 Linux/5.15.0-1037-azure

File hashes

Hashes for duck_orm-1.0.2.tar.gz
Algorithm Hash digest
SHA256 492b4d1beb0838ca3781b43fbf18d3a6f71f3263b76416cd5fe247500b4cd789
MD5 cb3175dfcafd84998710c6ca20db14dc
BLAKE2b-256 726ad9a7fff184e01270d3120cfab6ccfc68ec134292b286228544b03f3dcf0a

See more details on using hashes here.

File details

Details for the file duck_orm-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: duck_orm-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 15.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.9.16 Linux/5.15.0-1037-azure

File hashes

Hashes for duck_orm-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ffda0625834e7d343c5b12183ae56fdd450f44d91fdd0d06a83dd9e8c4031dc4
MD5 d941cac94ed67b29e7c8bbefddd177d0
BLAKE2b-256 9904822378f6569ae1475e344cde5ae0d4b6a23fd715f09df41c57c3a8f18823

See more details on using hashes here.

Supported by

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