Updated README.md and Italian -> Croatian

This commit is contained in:
Roan Song (SPAN)
2021-08-20 18:06:16 +02:00
parent b0fdc0d9b0
commit fee997aac6
2 changed files with 71 additions and 50 deletions

View File

@ -24,14 +24,14 @@
The `ormar` package is an async mini ORM for Python, with support for **Postgres, The `ormar` package is an async mini ORM for Python, with support for **Postgres,
MySQL**, and **SQLite**. MySQL**, and **SQLite**.
The main benefit of using `ormar` are: The main benefits of using `ormar` are:
* getting an **async ORM that can be used with async frameworks** (fastapi, starlette etc.) * getting an **async ORM that can be used with async frameworks** (fastapi, starlette etc.)
* getting just **one model to maintain** - you don't have to maintain pydantic and other orm model (sqlalchemy, peewee, gino etc.) * getting just **one model to maintain** - you don't have to maintain pydantic and other orm models (sqlalchemy, peewee, gino etc.)
The goal was to create a simple ORM that can be **used directly (as request and response models) with [`fastapi`][fastapi]** that bases it's data validation on pydantic. The goal was to create a simple ORM that can be **used directly (as request and response models) with [`fastapi`][fastapi]** that bases it's data validation on pydantic.
Ormar - apart form obvious ORM in name - get it's name from ormar in swedish which means snakes, and ormar(e) in croatian which means cabinet. Ormar - apart from the obvious "ORM" in name - gets its name from _ormar_ in Swedish which means _snakes_, and _ormar(e)_ in Croatian which means _cabinet_.
And what's a better name for python ORM than snakes cabinet :) And what's a better name for python ORM than snakes cabinet :)
@ -46,8 +46,8 @@ Check out the [documentation][documentation] for details.
**Note that for brevity most of the documentation snippets omit the creation of the database **Note that for brevity most of the documentation snippets omit the creation of the database
and scheduling the execution of functions for asynchronous run.** and scheduling the execution of functions for asynchronous run.**
If you want more real life examples than in the documentation you can see [tests][tests] folder, If you want more real life examples than in the documentation you can see the [tests][tests] folder,
since they actually have to create and connect to database in most of the tests. since they actually have to create and connect to a database in most of the tests.
Yet remember that those are - well - tests and not all solutions are suitable to be used in real life applications. Yet remember that those are - well - tests and not all solutions are suitable to be used in real life applications.
@ -61,7 +61,7 @@ As of now `ormar` is supported by:
* [`fastapi-crudrouter`](https://github.com/awtkns/fastapi-crudrouter) * [`fastapi-crudrouter`](https://github.com/awtkns/fastapi-crudrouter)
* [`fastapi-pagination`](https://github.com/uriyyo/fastapi-pagination) * [`fastapi-pagination`](https://github.com/uriyyo/fastapi-pagination)
If you maintain or use different library and would like it to support `ormar` let us know how we can help. If you maintain or use a different library and would like it to support `ormar` let us know how we can help.
### Dependencies ### Dependencies
@ -74,7 +74,7 @@ Ormar is built with:
### License ### License
`ormar` is built as an open-source software and remain completely free (MIT license). `ormar` is built as open-sorce software and will remain completely free (MIT license).
As I write open-source code to solve everyday problems in my work or to promote and build strong python As I write open-source code to solve everyday problems in my work or to promote and build strong python
community you can say thank you and buy me a coffee or sponsor me with a monthly amount to help ensure my work remains free and maintained. community you can say thank you and buy me a coffee or sponsor me with a monthly amount to help ensure my work remains free and maintained.
@ -94,7 +94,10 @@ community you can say thank you and buy me a coffee or sponsor me with a monthly
line-height: 0px; line-height: 0px;
height: 40px; height: 40px;
"> ">
<span style="color: #c9d1d9 !important;">Sponsor - Github Sponsors</span> <svg aria-hidden="true" viewBox="0 0 16 16" height="16" width="16" style="fill: #db61a2">
<path fill-rule="evenodd" d="M4.25 2.5c-1.336 0-2.75 1.164-2.75 3 0 2.15 1.58 4.144 3.365 5.682A20.565 20.565 0 008 13.393a20.561 20.561 0 003.135-2.211C12.92 9.644 14.5 7.65 14.5 5.5c0-1.836-1.414-3-2.75-3-1.373 0-2.609.986-3.029 2.456a.75.75 0 01-1.442 0C6.859 3.486 5.623 2.5 4.25 2.5zM8 14.25l-.345.666-.002-.001-.006-.003-.018-.01a7.643 7.643 0 01-.31-.17 22.075 22.075 0 01-3.434-2.414C2.045 10.731 0 8.35 0 5.5 0 2.836 2.086 1 4.25 1 5.797 1 7.153 1.802 8 3.02 8.847 1.802 10.203 1 11.75 1 13.914 1 16 2.836 16 5.5c0 2.85-2.045 5.231-3.885 6.818a22.08 22.08 0 01-3.744 2.584l-.018.01-.006.003h-.002L8 14.25zm0 0l.345.666a.752.752 0 01-.69 0L8 14.25z"></path>
</svg>
<span style="color: #c9d1d9 !important;">Sponsor</span>
</div> </div>
</a> </a>
@ -106,7 +109,7 @@ tool that can help you with translating existing sqlalchemy orm models so you do
**Beta** versions available at github: [`sqlalchemy-to-ormar`](https://github.com/collerek/sqlalchemy-to-ormar) **Beta** versions available at github: [`sqlalchemy-to-ormar`](https://github.com/collerek/sqlalchemy-to-ormar)
or simply `pip install sqlalchemy-to-ormar` or simply `pip install sqlalchemy-to-ormar`
**`sqlalchemy-to-ormar` can be used in pair with `sqlacodegen` to auto-map/ generate `ormar` models from existing database, even if you don't use the `sqlalchemy` for your project.** `sqlalchemy-to-ormar` can be used in pair with `sqlacodegen` to auto-map/ generate `ormar` models from existing database, even if you don't use `sqlalchemy` for your project.
### Migrations & Database creation ### Migrations & Database creation
@ -150,12 +153,12 @@ Note that `ormar` is an asynchronous ORM, which means that you have to `await` t
the methods, that are scheduled for execution in an event loop. Python has a builtin module the methods, that are scheduled for execution in an event loop. Python has a builtin module
[`asyncio`][asyncio] that allows you to do just that. [`asyncio`][asyncio] that allows you to do just that.
Note that most of "normal" python interpreters do not allow execution of `await` Note that most "normal" python interpreters do not allow execution of `await`
outside of a function (cause you actually schedule this function for delayed execution outside of a function (because you actually schedule this function for delayed execution
and don't get the result immediately). and don't get the result immediately).
In a modern web frameworks (like `fastapi`), the framework will handle this for you, but if In a modern web framework (like `fastapi`), the framework will handle this for you, but if
you plan to do this on your own you need to perform this manually like described in a you plan to do this on your own you need to perform this manually like described in the
quick start below. quick start below.
### Quick Start ### Quick Start
@ -334,20 +337,38 @@ async def delete():
async def joins(): async def joins():
# Tho join two models use select_related # Tho join two models use select_related
# Django style
book = await Book.objects.select_related("author").get(title="The Hobbit") book = await Book.objects.select_related("author").get(title="The Hobbit")
# Python style
book = await Book.objects.select_related(Book.author).get(
Book.title == "The Hobbit"
)
# now the author is already prefetched # now the author is already prefetched
assert book.author.name == "J.R.R. Tolkien" assert book.author.name == "J.R.R. Tolkien"
# By default you also get a second side of the relation # By default you also get a second side of the relation
# constructed as lowercase source model name +'s' (books in this case) # constructed as lowercase source model name +'s' (books in this case)
# you can also provide custom name with parameter related_name # you can also provide custom name with parameter related_name
# Django style
author = await Author.objects.select_related("books").all(name="J.R.R. Tolkien") author = await Author.objects.select_related("books").all(name="J.R.R. Tolkien")
# Python style
author = await Author.objects.select_related(Author.books).all(
Author.name == "J.R.R. Tolkien"
)
assert len(author[0].books) == 3 assert len(author[0].books) == 3
# for reverse and many to many relations you can also prefetch_related # for reverse and many to many relations you can also prefetch_related
# that executes a separate query for each of related models # that executes a separate query for each of related models
# Django style
author = await Author.objects.prefetch_related("books").get(name="J.R.R. Tolkien") author = await Author.objects.prefetch_related("books").get(name="J.R.R. Tolkien")
# Python style
author = await Author.objects.prefetch_related(Author.books).get(
Author.name == "J.R.R. Tolkien"
)
assert len(author.books) == 3 assert len(author.books) == 3
# to read more about relations # to read more about relations

View File

@ -31,7 +31,7 @@ The main benefits of using `ormar` are:
The goal was to create a simple ORM that can be **used directly (as request and response models) with [`fastapi`][fastapi]** that bases it's data validation on pydantic. The goal was to create a simple ORM that can be **used directly (as request and response models) with [`fastapi`][fastapi]** that bases it's data validation on pydantic.
Ormar - apart from the obvious "ORM" in name - gets its name from _ormar_ in Swedish which means _snakes_, and _ormar(e)_ in Italian which means _cabinet_. Ormar - apart from the obvious "ORM" in name - gets its name from _ormar_ in Swedish which means _snakes_, and _ormar(e)_ in Croatian which means _cabinet_.
And what's a better name for python ORM than snakes cabinet :) And what's a better name for python ORM than snakes cabinet :)