250 questions
1
vote
0
answers
69
views
How do I represent relationships? I get errors anyway I try
I have a sqlmodel defined database and I'm having issues with how to use sqlmodel. This is a two-table reduction of my DB.
from __future__ import annotations
import uuid
from datetime import datetime
...
0
votes
0
answers
32
views
Why doesn't SqlModel preform insert query in Llamaindex tool
I have an ai agent made with Python Llamaindex, FastAPI and SqlModel. I want to log the ToolCall in "search_documents" function but it never works.
The only problem is that ToolCall is not ...
0
votes
0
answers
122
views
How to define self-referencing relations in Python SQLModel ORM
I'm developing a FastAPI application, a file manager system, and I'm using PostgreSQL as the database. To define database entity models in my code, I previously used SQLAlchemy, but now I switched to ...
0
votes
2
answers
211
views
How to create a SQL View in SQLModel?
How can I create a view in SQLModel?
For instance, starting from this example taken from the user guide, which creates a table for Hero and a table for Team, where a Team can contain multiple Heros:
...
2
votes
2
answers
309
views
SQLModel and emails
I'm currently working on an api using fastapi and sqlmodel. I'm new to these two and I might have missed something.
I have a user model with an e-mail field. So no email outside my organization is ...
0
votes
0
answers
54
views
Issue updating children in sqlmodel from remote API update
The context is a menu-like hierarchy eg:
parent > child > grandchild in a recursive manner (eg. child can have children), they are linked by the menu_parent_id. The top-most MenuGroup has no ...
1
vote
2
answers
308
views
How to freeze time without freezegun?
I'm writing integration tests with pytest for my FastAPI/SQLModel app, and I was looking for a way to freeze time directly inside the app.
While freezegun works fine in basic scenarios like unit tests,...
1
vote
1
answer
233
views
Best way to convert FastAPI/SQLmodel into Polars Dataframe?
What is best way to convert a FastAPI query into a Polars (or pandas) dataframe.
Co-pilot give this.
with Session(engine) as session:
questions = session.exec(select(Questions)).all()
...
0
votes
0
answers
102
views
polars.read_database() Fails with Enum Type when Using schema_overrides
I have a database table with an Enum column. My application does transforms with polars, so I'm reading with the pl.read_database() method. However reading the table when schema_overrides is supplied ...
0
votes
1
answer
116
views
How to `assert_called_with` an object instance?
I want to do a unittest with pytest for this method:
class UserService:
@classmethod
async def get_user_by_login(cls, session: SessionDep, login: str) -> Optional[User]:
sql = ...
0
votes
1
answer
99
views
have SQLAlchemy or SQLModel define a database schema starting from an example of the object I would like to persist
I would like to save objects like this to a local database.
The object is a dictionary with various entries.
For instance, the first entries are like:
"id": "https://openalex.org/...
1
vote
1
answer
122
views
Fastadmin does not record the registration of the class model
My user model inherits from fastapi-users lib.
When I try to log into the admin panel I get an error "User model is not registered."
from core.models import Base
from fastapi_users.db import ...
0
votes
1
answer
116
views
Azure SQL Database keeps disconnecting using SQLAlchemy Sessionmaker
I'm trying to get an azure sql db working. I am using FastAPI, SQLModel and SQLAlchemy
from sqlmodel import create_engine, SQLModel, Session
def init_db(settings: SqlDBSettings = SqlDBSettings()):
...
1
vote
2
answers
215
views
How do I write a join in FastAPI with SQLModel?
almost exact question, 2 years old, no responses: Deep nesting response model in fastapi using sqlmodel
My question is like this one but I have an error: Not able to get data for joining two tables in ...
2
votes
1
answer
262
views
SQLModel session handling when my read and updates are in seperate parts of the code flow
I have a script that needs to query some data, process it, and then update some columns in the row I read.
My code looks like this:
def query_data(param1):
with Session(engine) as session:
...