Ormdantic

Latest version: v1.7.0

Safety actively analyzes 682244 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 2 of 2

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.

python
Count
count = await database[Flavor].count()
print(count)


* It's support also `Where` and `Depth`

python
count_advanced = await database[Coffee].count(
where={"sweetener": 2}, depth=1
)
print(count_advanced)


* :green_heart: Support Python 3.11 by yezz123 in https://github.com/yezz123/ormdantic/pull/42
* fix: Improve field type translation by iron3oxide in https://github.com/yezz123/ormdantic/pull/44
* ✨ Introduce the `count()` Feature by yezz123 in https://github.com/yezz123/ormdantic/pull/50


**Full Changelog**: https://github.com/yezz123/ormdantic/compare/1.3.0...1.4.0

1.3.0

What's Changed
* Docs: Build Documentation for `Ormdantic` by yezz123 in https://github.com/yezz123/ormdantic/pull/23
* docs: Update FAQ by iron3oxide in https://github.com/yezz123/ormdantic/pull/26
* Convert comparison to SQLModel to table and update claims by iron3oxide in https://github.com/yezz123/ormdantic/pull/27
* Fix code block format in comparison table by iron3oxide in https://github.com/yezz123/ormdantic/pull/28
* Refactoring: Improve the Generator for Both `Crud` & `Table` Classes by yezz123 in https://github.com/yezz123/ormdantic/pull/29
* 👷🏻 Add Integration Integrations Tests by yezz123 in https://github.com/yezz123/ormdantic/pull/36
* :green_heart: Migrate to Hatchling by yezz123 in https://github.com/yezz123/ormdantic/pull/38

New Contributors
* iron3oxide made their first contribution in https://github.com/yezz123/ormdantic/pull/26

**Full Changelog**: https://github.com/yezz123/ormdantic/compare/1.2.0...1.3.0

1.2.0

What's Changed
* ✨ chore(fix): `Ormdantic` takes connection `str` instead of `engine` by yezz123 in https://github.com/yezz123/ormdantic/pull/18


**Full Changelog**: https://github.com/yezz123/ormdantic/compare/1.1.0...1.2.0

1.1.0

![Logo](https://raw.githubusercontent.com/yezz123/ormdantic/main/.github/logo.png)

<p align="center">
<em>Asynchronous ORM that uses pydantic models to represent database tables ✨</em>
</p>


Ormdantic is a library for interacting with Asynchronous <abbr title='Also called "Relational databases"'>SQL databases</abbr> from Python code, with Python objects. It is intuitive, easy to use, compatible, and robust.

**Ormdantic** is based on [Pypika](https://github.com/kayak/pypika), and powered by <a href="https://pydantic-docs.helpmanual.io/" class="external-link" target="_blank">Pydantic</a> and <a href="https://sqlalchemy.org/" class="external-link" target="_blank">SQLAlchemy</a>, and Highly inspired by <a href="https://github.com/tiangolo/Sqlmodel" class="external-link" target="_blank">Sqlmodel</a>, Created by [tiangolo](https://github.com/tiangolo).

> What is [Pypika](https://github.com/kayak/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, <a href="https://www.python.org/downloads/" class="external-link" target="_blank">Python supports versions 3.10 and above</a>).

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:

shell
$ pip install ormdantic

---> 100%

Successfully installed Ormdantic


* Install The specific Asynchronous ORM library for your database.

shell
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](https://sqlmodel.tiangolo.com/).

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.

python
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](https://docs.sqlalchemy.org/en/14/core/engines.html) for more information.


What's Changed
* Chore(feat): Improve many to many relationships & add New tests by yezz123 in https://github.com/yezz123/ormdantic/pull/15


**Full Changelog**: https://github.com/yezz123/ormdantic/compare/1.0.0...1.1.0

1.0.0

![Logo](https://raw.githubusercontent.com/yezz123/ormdantic/main/.github/logo.png)

<p align="center">
<em>Asynchronous ORM that uses pydantic models to represent database tables ✨</em>
</p>


Ormdantic is a library for interacting with Asynchronous <abbr title='Also called "Relational databases"'>SQL databases</abbr> from Python code, with Python objects. It is designed to be intuitive, easy to use, compatible, and robust.

**Ormdantic** is based on [Pypika](https://github.com/kayak/pypika), and powered by <a href="https://pydantic-docs.helpmanual.io/" class="external-link" target="_blank">Pydantic</a> and <a href="https://sqlalchemy.org/" class="external-link" target="_blank">SQLAlchemy</a>, and Highly inspired by <a href="https://github.com/tiangolo/Sqlmodel" class="external-link" target="_blank">Sqlmodel</a>, Created by [tiangolo](https://github.com/tiangolo).

> What is [Pypika](https://github.com/kayak/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, <a href="https://www.python.org/downloads/" class="external-link" target="_blank">Python supports versions 3.10 and above</a>).

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:

shell
$ pip install ormdantic

---> 100%

Successfully installed Ormdantic


* Install The specific Asynchronous ORM library for your database.

shell
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](https://sqlmodel.tiangolo.com/).

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.

python
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](https://docs.sqlalchemy.org/en/14/core/engines.html) for more information.

Page 2 of 2

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.