Releases: yezz123/ormdantic
1.7.0
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
- ⬆ Bump samuelcolvin/check-python-version from 3.1 to 4.1. PR #175 by @dependabot.
- ⬆ Bump mypy from 1.7.1 to 1.8.0. PR #174 by @dependabot.
- ⬆ Bump pymdown-extensions from 10.5 to 10.7. PR #176 by @dependabot.
- ⬆ Bump pytest from 7.4.3 to 7.4.4. PR #177 by @dependabot.
- ⬆ Bump pytest-asyncio from 0.23.2 to 0.23.3. PR #178 by @dependabot.
- ⬆ Bump jinja2 from 3.1.2 to 3.1.3. PR #179 by @dependabot.
- ⬆ Bump codecov/codecov-action from 3 to 4. PR #183 by @dependabot.
- ⬆ Bump pytest-asyncio from 0.23.3 to 0.23.4. PR #182 by @dependabot.
- ⬆ Bump pre-commit from 3.6.0 to 3.6.1. PR #186 by @dependabot.
- ⬆ Bump pytest-asyncio from 0.23.4 to 0.23.5. PR #185 by @dependabot.
- ⬆ Bump pre-commit/action from 3.0.0 to 3.0.1. PR #184 by @dependabot.
- ⬆ Bump pre-commit from 3.6.1 to 3.6.2. PR #187 by @dependabot.
- ⬆ Bump pytest from 7.4.4 to 8.0.1. PR #188 by @dependabot.
- ⬆ Bump pytest from 8.0.1 to 8.0.2. PR #190 by @dependabot.
- ⬆ Update typing-extensions requirement from <4.10.0,>=3.7.4 to >=3.7.4,<4.11.0. PR #189 by @dependabot.
- ⬆ Bump pypa/gh-action-pypi-publish from 1.8.11 to 1.8.12. PR #191 by @dependabot.
- ⬆ Bump pytest from 8.0.2 to 8.1.0. PR #192 by @dependabot.
- ⬆ Bump pytest from 8.1.0 to 8.1.1. PR #197 by @dependabot.
- ⬆ Bump pypa/gh-action-pypi-publish from 1.8.12 to 1.8.14. PR #193 by @dependabot.
- ⬆ Bump pymdown-extensions from 10.7 to 10.7.1. PR #196 by @dependabot.
- ⬆ Bump mypy from 1.8.0 to 1.9.0. PR #195 by @dependabot.
- ⬆ Bump pytest-asyncio from 0.23.5 to 0.23.5.post1. PR #194 by @dependabot.
1.6.1
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 📦
- ⬆ Bump pytest from 7.3.1 to 7.3.2 by @dependabot in #132
- ⬆ Bump pre-commit from 3.3.2 to 3.3.3 by @dependabot in #133
- ⬆ Bump pytest from 7.3.2 to 7.4.0 by @dependabot in #134
- ⬆ Bump mypy from 1.3.0 to 1.4.1 by @dependabot in #135
- ⬆ Update typing-extensions requirement from <4.7.0,>=3.7.4 to >=3.7.4,<4.8.0 by @dependabot in #136
- ⬆ Bump pypa/gh-action-pypi-publish from 1.8.6 to 1.8.7 by @dependabot in #138
- ⬆ Bump mkdocs-mermaid2-plugin from 0.6.0 to 1.0.6 by @dependabot in #145
- ⬆ Bump mkdocs-mermaid2-plugin from 1.0.6 to 1.1.1 by @dependabot in #151
- ⬆ Bump pymdown-extensions from 10.0.1 to 10.3 by @dependabot in #148
- ⬆ Bump pytest-asyncio from 0.21.0 to 0.21.1 by @dependabot in #140
- ⬆ Bump pypa/gh-action-pypi-publish from 1.8.7 to 1.8.10 by @dependabot in #147
- ⬆ Bump actions/checkout from 3 to 4 by @dependabot in #150
- ⬆ Bump mypy from 1.4.1 to 1.6.1 by @dependabot in #157
- ⬆ Bump pre-commit from 3.3.3 to 3.5.0 by @dependabot in #156
- ⬆ Bump pytest from 7.4.0 to 7.4.2 by @dependabot in #154
- ⬆ Update typing-extensions requirement from <4.8.0,>=3.7.4 to >=3.7.4,<4.9.0 by @dependabot in #160
- ⬆ Bump pytest from 7.4.2 to 7.4.3 by @dependabot in #158
- ⬆ Bump pymdown-extensions from 10.3 to 10.3.1 by @dependabot in #159
- ⬆ Bump mypy from 1.6.1 to 1.7.1 by @dependabot in #164
- ⬆ Bump pymdown-extensions from 10.3.1 to 10.5 by @dependabot in #165
- ⬆ Bump pypa/gh-action-pypi-publish from 1.8.10 to 1.8.11 by @dependabot in #166
- ⬆ Bump pytest-asyncio from 0.21.1 to 0.23.2 by @dependabot in #167
- ⬆ Update typing-extensions requirement from <4.9.0,>=3.7.4 to >=3.7.4,<4.10.0 by @dependabot in #170
- ⬆ Bump actions/setup-python from 4 to 5 by @dependabot in #169
- ⬆ Bump pre-commit from 3.5.0 to 3.6.0 by @dependabot in #168
Full Changelog: 1.6.0...1.6.1
1.6.0
What's Changed
- ➖ Remove Workflow for documentation by @yezz123 in #114
- ✨ Combine all workflows in one & Update Coverage configuration by @yezz123 in #128
Internal
- ⬆ Update mkdocs-material requirement from <9.0.0,>=8.1.4 to >=8.1.4,<10.0.0 by @dependabot in #80
- ⬆ Bump pymdown-extensions from 9.9 to 9.9.1 by @dependabot in #82
- ⬆ Bump pytest from 7.2.0 to 7.2.1 by @dependabot in #83
- ⬆ Bump pymdown-extensions from 9.9.1 to 9.9.2 by @dependabot in #85
- ⬆ Bump pre-commit from 2.21.0 to 3.0.0 by @dependabot in #86
- ⬆ Bump pre-commit from 3.0.0 to 3.0.1 by @dependabot in #88
- ⬆ Update sqlalchemy[asyncio] requirement from <1.5.0,>=1.3.18 to >=1.3.18,<2.1.0 by @dependabot in #87
- ⬆ Bump pre-commit from 3.0.1 to 3.0.2 by @dependabot in #89
- ⬆ Bump pytest-pretty from 1.0.1 to 1.1.0 by @dependabot in #91
- ⬆ Bump pre-commit from 3.0.2 to 3.0.3 by @dependabot in #90
- ⬆ Bump pre-commit from 3.0.3 to 3.0.4 by @dependabot in #92
- ⬆ Bump mypy from 0.991 to 1.0.0 by @dependabot in #93
- ⬆ Bump markdown-include from 0.8.0 to 0.8.1 by @dependabot in #94
- ⬆ Update typing-extensions requirement from <4.5.0,>=3.7.4 to >=3.7.4,<4.6.0 by @dependabot in #95
- ⬆ Bump mypy from 1.0.0 to 1.0.1 by @dependabot in #96
- ⬆ Bump pre-commit from 3.0.4 to 3.1.0 by @dependabot in #97
- ⬆ Bump pre-commit from 3.1.0 to 3.1.1 by @dependabot in #98
- ⬆ Bump pytest from 7.2.1 to 7.2.2 by @dependabot in #99
- ⬆ Bump pymdown-extensions from 9.9.2 to 9.10 by @dependabot in #100
- ⬆ Bump mypy from 1.0.1 to 1.1.1 by @dependabot in #101
- ⬆ Bump pypa/gh-action-pypi-publish from 1.6.4 to 1.8.0 by @dependabot in #103
- ⬆ Bump pypa/gh-action-pypi-publish from 1.8.0 to 1.8.1 by @dependabot in #104
- ⬆ Bump pytest-asyncio from 0.20.3 to 0.21.0 by @dependabot in #105
- ⬆ Bump pre-commit from 3.1.1 to 3.2.0 by @dependabot in #106
- ⬆ Bump pytest-pretty from 1.1.0 to 1.1.1 by @dependabot in #107
- ⬆ Bump pypa/gh-action-pypi-publish from 1.8.1 to 1.8.3 by @dependabot in #108
- ⬆ Bump pre-commit from 3.2.0 to 3.2.1 by @dependabot in #109
- ⬆ Bump pypa/gh-action-pypi-publish from 1.8.3 to 1.8.4 by @dependabot in #110
- ⬆ Bump pytest-pretty from 1.1.1 to 1.2.0 by @dependabot in #113
- ⬆ Bump pre-commit from 3.2.1 to 3.2.2 by @dependabot in #112
- ⬆ Bump pypa/gh-action-pypi-publish from 1.8.4 to 1.8.5 by @dependabot in #111
- ⬆ Bump mypy from 1.1.1 to 1.2.0 by @dependabot in #115
- ⬆ Bump pytest from 7.2.2 to 7.3.0 by @dependabot in #116
- ⬆ Bump pymdown-extensions from 9.10 to 9.11 by @dependabot in #117
- ⬆ Bump pytest from 7.3.0 to 7.3.1 by @dependabot in #118
- ⬆ Bump codecov from 2.1.12 to 2.1.13 by @dependabot in #119
- ⬆ Bump pypa/gh-action-pypi-publish from 1.8.5 to 1.8.6 by @dependabot in #121
- ⬆ Bump mypy from 1.2.0 to 1.3.0 by @dependabot in #123
- ⬆ Bump pymdown-extensions from 9.11 to 10.0.1 by @dependabot in #124
- ⬆ Bump pre-commit from 3.2.2 to 3.3.2 by @dependabot in #125
- ⬆ Update typing-extensions requirement from <4.6.0,>=3.7.4 to >=3.7.4,<4.7.0 by @dependabot in #126
- ⬆ Bump pytest-cov from 4.0.0 to 4.1.0 by @dependabot in #127
Full Changelog: 1.5.1...1.6.0
1.5.1
What's Changed
- ✨ Added support for the
StrictInt
andStrictFloat
types by @yezz123 in #74 - ✨ Support constrained lists by @yezz123 in #75
- ✨ Support ForwardRef by @yezz123 in #76
Internal
- ⬆ Bump pre-commit from 2.20.0 to 2.21.0 by @dependabot in #77
- 🎨 Upgrade
pre-commit
& Support Ruff by @yezz123 in #78
Full Changelog: 1.5.0...1.5.1
1.5.0
What's Changed
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
- ⬆ Bump pymdown-extensions from 9.7 to 9.8 by @dependabot in #61
- ⬆ Bump mypy from 0.982 to 0.990 by @dependabot in #62
- ⬆ Bump pytest-asyncio from 0.20.1 to 0.20.2 by @dependabot in #63
- ⬆ Bump mypy from 0.990 to 0.991 by @dependabot in #64
- ⬆ Bump pymdown-extensions from 9.8 to 9.9 by @dependabot in #66
- ⬆ Bump markdown-include from 0.7.0 to 0.8.0 by @dependabot in #65
- ⬆ Bump pypa/gh-action-pypi-publish from 1.5.1 to 1.5.2 by @dependabot in #67
- ⬆ Bump pypa/gh-action-pypi-publish from 1.5.2 to 1.6.1 by @dependabot in #69
- ⬆ Bump pypa/gh-action-pypi-publish from 1.6.1 to 1.6.4 by @dependabot in #70
- ⬆ Bump pytest-asyncio from 0.20.2 to 0.20.3 by @dependabot in #71
Full Changelog: 1.4.1...1.5.0
Support Py3.11
- Support Python 3.11, and add it to classifiers.
What's Changed
- ⬆ Bump
pytest-asyncio
from 0.18.3 to 0.20.1 by @dependabot in #56 - ⬆ Bump
pre-commit
from 2.19.0 to 2.20.0 by @dependabot in #57 - ⬆ Bump
mkdocs-mermaid2-plugin
from 0.5.2 to 0.6.0 by @dependabot in #58 - ⬆ Bump
pymdown-extensions
from 9.1 to 9.7 by @dependabot in #59 - ⬆ Bump
pytest-cov
from 3.0.0 to 4.0.0 by @dependabot in #60
New Contributors
- @dependabot made their first contribution in #56
Full Changelog: 1.4.0...1.4.1
1.4.0
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
andDepth
count_advanced = await database[Coffee].count(
where={"sweetener": 2}, depth=1
)
print(count_advanced)
- 💚 Support Python 3.11 by @yezz123 in #42
- fix: Improve field type translation by @iron3oxide in #44
- ✨ Introduce the
count()
Feature by @yezz123 in #50
Full Changelog: 1.3.0...1.4.0
1.3.0
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
- @iron3oxide made their first contribution in #26
Full Changelog: 1.2.0...1.3.0
1.2.0
1.1.0
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
Full Changelog: 1.0.0...1.1.0