How do I fix error “sqlalchemy.exc.MissingGreenlet: greenlet_spawn has not been called; can’t call await_only() here”?
I had SQLalchemy error sqlalchemy.exc.MissingGreenlet: greenlet_spawn has not been called; can't call await_only() here. Was IO attempted in an unexpected place?
. I tried to fix it, and now it kind of works, but I’m interested in whether it works correctly?
How to use AsyncSession.sync_session or how to have both sync and async session with the same scope of objects, single transaction?
I’d like to use AsyncSession.sync_session
but the code below fails with error. The code is a simplified version of real case.
Handling concurrency race in sqlalchemy
I don’t understand how to avoid concurrency when there are more sessions.
Let’s imagine there are some table User:
Comparing different methods of rolling back database changes in pytest tests for SQLAlchemy
I’m working on a project that uses FastAPI and SQLAlchemy asynchronously.
I’ve written pytest tests for this project and have successfully implemented database rollback after each test run.
I’ve found two different implementation methods, but I’m unsure about the differences between them. Are both methods correct, or is one potentially problematic?
sqlalchemy.exc.InvalidRequestError:
I get this error: I don’t understand how to solve it,
I get this error when I run uvicorn
Sqlalchemy + FastAPI. Return ORM model result with nested childs
I have table “categories” with subcategories. Subcategories are determined by “parent_id”.
Sqlalchemy + FastAPI. Return ORM model result with nested childs
I have table “categories” with subcategories. Subcategories are determined by “parent_id”.
CRUD operation with FastAPI and sqlalchemy
I’m new to python and fastapi and i’m to create a simple CRUD to create a user and if the user gets created correctly, create a blank profile with the user_id
of the created user.
Retrieve JSON objects
model class MyGPTs(Base): __tablename__ = “my_gpts” __table_args__ = {‘extend_existing’: True} # Add this line id = Column(Integer, primary_key=True) bot_identifier = Column(String, nullable=False, default=”bot”) unique_id = Column(String, nullable=True, default=str(ObjectId())) user_id = Column(String, nullable=True) account_id = Column(String, nullable=False) project_id = Column(String, nullable=False) name = Column(String, nullable=True) app_type = Column(Integer, ForeignKey(“app_types.id”)) profile_image = Column(String, nullable=False) bot_type = Column(String, […]
Dynamic query parameters
I implement FastAPI, SQLAlchemy service that has integration with ERM software. ERM software stores data in table as