Skip to content

Releases: yezz123/ormdantic

1.7.0

19 Apr 04:15
00c6b57
Compare
Choose a tag to compare

Features

Internal

  • 👷 Add setup for uv and use uv for dependency installation. PR #198 by @yezz123.
  • 🔨 Migrate to use UV For Dependencies Management. PR #200 by @yezz123.
  • 👷 Add latest-changes workflow action. PR #203 by @yezz123.

Docs

  • 📝 Generate API documentation & add docstrings. PR #206 by @yezz123.
  • 📝 refactor documentation. PR #205 by @yezz123.
  • 📝 Add configuration code for termynal. PR #204 by @yezz123.

Dependencies

1.6.1

24 Dec 16:39
ac81411
Compare
Choose a tag to compare

What's Changed

Fixes 🐛

  • ➕ Add python312 by @yezz123 in #161
  • ♻️ refactor the CI & support testing in different OS by @yezz123 in #172
  • 🔧 switch to fully configure ruff for formatting by @yezz123 in #173

Dependencies 📦

Full Changelog: 1.6.0...1.6.1

1.6.0

03 Jun 16:34
619b275
Compare
Choose a tag to compare

What's Changed

  • ➖ Remove Workflow for documentation by @yezz123 in #114
  • ✨ Combine all workflows in one & Update Coverage configuration by @yezz123 in #128

Internal

Full Changelog: 1.5.1...1.6.0

1.5.1

02 Jan 09:39
4277ccc
Compare
Choose a tag to compare

What's Changed

  • ✨ Added support for the StrictInt and StrictFloat types by @yezz123 in #74
  • ✨ Support constrained lists by @yezz123 in #75
  • ✨ Support ForwardRef by @yezz123 in #76

Internal

Full Changelog: 1.5.0...1.5.1

1.5.0

15 Dec 08:47
Compare
Choose a tag to compare

What's Changed

  • Introduce generator for Pydantic Model by @yezz123 in #73

Usage

Given a Pydantic model type can generate instances of that model with randomly generated values.

Example

from enum import auto, Enum
from uuid import UUID

from ormdantic.generator import Generator
from pydantic import BaseModel


class Flavor(Enum):
    MOCHA = auto()
    VANILLA = auto()


class Brand(BaseModel):
    brand_name: str


class Coffee(BaseModel):
    id: UUID
    description: str
    cream: bool
    sweetener: int
    flavor: Flavor
    brand: Brand


print(Generator(Coffee))
  • Result:
id=UUID('93b517c2-083b-457d-a0e5-6e1bd2a927e4')
description='ctWOb' cream=True sweetener=234
flavor=<Flavor.VANILLA: 2> brand=Brand(brand_name='LMrIf')

Internal

Full Changelog: 1.4.1...1.5.0

Support Py3.11

06 Nov 10:35
ee3082f
Compare
Choose a tag to compare
  • Support Python 3.11, and add it to classifiers.

What's Changed

New Contributors

Full Changelog: 1.4.0...1.4.1

1.4.0

21 Oct 23:06
b00c80f
Compare
Choose a tag to compare

What's Changed

Count

To count the number of rows of a table or in a result set you can use the count function.

     # Count
     count = await database[Flavor].count()
     print(count)
  • It's support also Where and Depth
     count_advanced = await database[Coffee].count(
          where={"sweetener": 2}, depth=1
     )
     print(count_advanced)

Full Changelog: 1.3.0...1.4.0

1.3.0

17 Sep 13:31
9e1b815
Compare
Choose a tag to compare

What's Changed

  • Docs: Build Documentation for Ormdantic by @yezz123 in #23
  • docs: Update FAQ by @iron3oxide in #26
  • Convert comparison to SQLModel to table and update claims by @iron3oxide in #27
  • Fix code block format in comparison table by @iron3oxide in #28
  • Refactoring: Improve the Generator for Both Crud & Table Classes by @yezz123 in #29
  • 👷🏻 Add Integration Integrations Tests by @yezz123 in #36
  • 💚 Migrate to Hatchling by @yezz123 in #38

New Contributors

Full Changelog: 1.2.0...1.3.0

1.2.0

26 Aug 20:05
d84e00e
Compare
Choose a tag to compare

What's Changed

  • ✨ chore(fix): Ormdantic takes connection str instead of engine by @yezz123 in #18

Full Changelog: 1.1.0...1.2.0

1.1.0

22 Aug 21:55
d0687dc
Compare
Choose a tag to compare

Logo

Asynchronous ORM that uses pydantic models to represent database tables ✨

Ormdantic is a library for interacting with Asynchronous SQL databases from Python code, with Python objects. It is intuitive, easy to use, compatible, and robust.

Ormdantic is based on Pypika, and powered by Pydantic and SQLAlchemy, and Highly inspired by Sqlmodel, Created by @tiangolo.

What is Pypika?

PyPika is a Python API for building SQL queries. The motivation behind PyPika is to provide a simple interface for building SQL queries without limiting the flexibility of handwritten SQL. Designed with data analysis in mind, PyPika leverages the builder design pattern to construct queries to avoid messy string formatting and concatenation. It is also easily extended to take full advantage of specific features of SQL database vendors.

The key features are:

  • Easy to use: It has sensible defaults and does a lot of work underneath to simplify the code you write.
  • Compatible: It combines SQLAlchemy, Pydantic and Pypika tries to simplify the code you write as much as possible, allowing you to reduce the code duplication to a minimum, but while getting the best developer experience possible.
  • Extensible: You have all the power of SQLAlchemy and Pypika underneath.
  • Short Queries: You can write queries in a single line of code, and it will be converted to the appropriate syntax for the database you are using.

Requirements

A recent and currently supported version of Python (right now, Python supports versions 3.10 and above).

As Ormdantic is based on Pydantic and SQLAlchemy and Pypika, it requires them. They will be automatically installed when you install Ormdantic.

Installation

You can add Ormdantic in a few easy steps. First of all, install the dependency:

$ pip install ormdantic

---> 100%

Successfully installed Ormdantic
  • Install The specific Asynchronous ORM library for your database.
# MySQL
$ pip install ormdantic[mysql]

# PostgreSQL
$ pip install ormdantic[postgres]

# SQLite
$ pip install ormdantic[sqlite]

Example

To understand SQL, Sebastian the Creator of FastAPI and SQLModel created an amazing documentation that could help you understand the basics of SQL, ex. CREATE TABLE, INSERT, SELECT, UPDATE, DELETE, etc.

Check out the documentation.

But let's see how to use Ormdantic.

Create SQLAlchemy engine

Ormdantic uses SQLAlchemy under hood to run different queries, which is why we need to initialize by creating an asynchronous engine.

from sqlalchemy.ext.asyncio import create_async_engine as create_engine
from ormdantic import Ormdantic

engine = create_engine("sqlite+aiosqlite:///db.sqlite3")
database = Ormdantic(engine)

Note: You can use any asynchronous engine, check out the documentation for more information.

What's Changed

  • Chore(feat): Improve many to many relationships & add New tests by @yezz123 in #15

Full Changelog: 1.0.0...1.1.0