Questions tagged [ormar]

This tag is for questions about ormar async ORM, used standalone or with FastAPI.

Ormar is an async mini ORM for Python, with support for Postgres, MySQL, and SQLite. Main benefits:

  • 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 like sqlalchemy, peewee, gino etc.)
  • simple ORM than can be used directly (as request and response models) with FastAPI, that bases its data validation on pydantic.
13 questions
3
votes
1 answer

Alembic migrations in ormar not working (FastAPI)

I want to migrate through Alembic, but something doesn't work. I don't understand what exactly I'm doing wrong. My alembic .env from logging.config import fileConfig from sqlalchemy import create_engine from sqlalchemy import…
2
votes
0 answers

Python async SQL ORM with custom SQL lazy querysets

I generally use Python ORMs like Tortoise ORM or Ormar ORM (because they're async, integrate well with FastAPI, have very good performances (for Tortoise ORM), can use single Pydantic/type-hinted models (for Ormar). And of course also from…
bolino
  • 867
  • 1
  • 10
  • 27
2
votes
1 answer

Switch to test database using FastAPI and ormar

I am trying ormar with FastAPI and struggling with testing. Because I use Django in the majority of my projects, I am trying to separate my databases between development and testing. But I am struggling to do this. The goal is basically, use…
dropscar
  • 113
  • 2
  • 10
1
vote
0 answers

Unable to achieve async/parallel behavior inside for loop while using FastAPI and Ormar

I am using FastAPI and have an async route that needs to do many things like making calls to other API endpoints, and reading/writing to a database. It iterates over a list of customers (around 500). I used ThreadPoolExectuor before to achieve…
1
vote
1 answer

synchronous execution of database (postgres) query using asyncio not working together with ormar ORM (fastapi app)

I'm building an api using fastapi with postgres and ormar for ORM (currently using docker-compose to develop locally). Routes are working fine, but I'm having trouble adding JWT user authorization using the natively async ormar to confirm users in…
svedel
  • 79
  • 1
  • 1
  • 4
0
votes
0 answers

How can I set alias for ormar package query in python

Preface Recently, I am using ormar package work with fastapi web framework. With MySQL statement we can use select id as OrderId from orders to create an alias for id filed, in ormar package, I can't find how to create alias when I use query…
ssayno
  • 51
  • 7
0
votes
0 answers

Nested JSON response with FastAPI and Ormar

I've got 3 database models; Graphs, Nodes and Paths. Graphs have nodes and nodes have paths and paths have destination and source nodes. Here is the models (I am using ormar ORM): class Graph(BaseModel): """Model for Graph objects.""" class…
mdegis
  • 2,078
  • 2
  • 21
  • 39
0
votes
0 answers

Validating model URL type using ORMAR

I have a model, Users class Users(ormar.Model): class Meta(BaseMeta): tablename = "users" id: int = ormar.Integer(primary_key=True) first_name: str = ormar.String(max_length=255) middle_name: Union[str, None] =…
код е
  • 196
  • 2
  • 11
0
votes
0 answers

Why does the URL string of my API filter have a forward slash instead of an equal sign?

The request for an ID does return a record correctly, but the URL has the record being searched in front of a "/" in the address bar: http://fastapi.localhost:8008/person/2 Below is my request paramter for a GET request: @app.get("/person/{id}",…
IamTrying
  • 39
  • 6
0
votes
1 answer

ForeignKey error in ormar has no attribute 'get_column_alias'

I'm testing out ormar to avoid having to create models for both api and database and ran into an issue with foreignkey assignment I can't seem to figure out. The base code works before I deleted the database and try to recreate again with the new…
user1204369
  • 299
  • 2
  • 3
  • 10
0
votes
1 answer

Alembic autogenerate doesn't detect column detect on parent class (Alembic + Ormar ORM)

Here what I want to achieve, I want models common fields inside a base model namely BaseModel as pictured below. Mixins class TimeStampMixin: created: datetime.datetime = ormar.DateTime(default=datetime.datetime.now) updated:…
user13837279
  • 77
  • 1
  • 3
0
votes
1 answer

python posgresql ormar truncate table

i am currently using ormar in python for postgresql stuff and i am learning as well. by using this docker git with fastapi, postgress and traefik as template to start my project, i found out the example is using ormar inside and so i try to use it…
user1897151
  • 493
  • 2
  • 9
  • 28
0
votes
1 answer

Encountered an error setting up ORM ormar

Started learning fastAPI and when setup ormar. I got this error Traceback (most recent call last): File "/usr/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap self.run() File "/usr/lib/python3.8/multiprocessing/process.py",…
Bob
  • 129
  • 2
  • 9