23,620 questions
0
votes
0
answers
26
views
How to correctly compare two encoded jwt refresh tokens
I using jwt in fastpai app, and when I create access and refresh tokens on user login I also create user session for specific user id in database, so as I understood I need to encrypt refresh token ...
-2
votes
0
answers
46
views
order by for jsonb_build_object function in SQLALCHEMY // POSTGRES
I have a following CTE written in sqlalchemy
all_notes_cte = (
select(
notes_association_table.c.op_id,
func.jsonb_agg(
func....
Advice
0
votes
1
replies
45
views
Why does engine.execute() not work for merge statements?
I'm looking for some advice on how different connection methods work.
Let's say I have two tables:
Table_1 has a column named column_2 which is entirely null.
Table_2 has a column named column_2 ...
-1
votes
1
answer
49
views
SQLAlchemyAsyncRepository object has no attribute 'get_many'
I'm learning litestar and I can't figure out SQLAlchemyAsyncRepository.
I created the repository this way
class ReservationRepository(repository.SQLAlchemyAsyncRepository[ReservationModel]):
...
2
votes
1
answer
123
views
Python SQLAlchemy dynamically build select statements
I am currently trying to write a function that takes arguments, if the arguments are not false then it builds the select statement with them in it. I am unable to get it to work unless I am too build ...
Best practices
0
votes
6
replies
207
views
The multiple choices in a database
I'm building a web application that has ~34 independent dropdown lists (e.g. currency codes, country names, user types, example statuses, etc.). Each list has no relation to the others — they're ...
0
votes
1
answer
92
views
Concurrent update error: race condition error in FastAPI
I have a function, that updated database
@router.put("/{task_id}/status")
def update_status(task_id: str, task_data: UpdateStatus, db: Session = Depends(get_db)):
task = ...
0
votes
1
answer
62
views
Using shell to interact with database in SQLAlchemy
I am trying to learn FastAPI, and I want to interact with the database using SQLAlchemy from the shell or terminal to practice more about SQLAlchemy.
So I used my sync-db to reach the database but ...
0
votes
1
answer
133
views
SQLAlchemy query to get keys from a JSON as an array, not separate rows
Suppose I have a SQLAlchemy model that looks like this:
class MyModel(meta.Base)
id = Column(BigInteger, autoincrement=True, primary_key=True)
extra_data = Column(postgresql.JSON, nullable=...
0
votes
0
answers
146
views
Why doesn't my alembic sync to my docker database but it works in production?
I have an Alembic and SQLAlchemy defined database that's working just fine updating my database when I run
alembic -c traveler/db/alembic.ini upgrade head
Everything gets updated to the new models.
I'...
Best practices
0
votes
2
replies
76
views
How to write a (postgresql) SqlAlchemy filter that checks if a JSONB column has exactly this list of keys?
Suppose I have a SQLAlchemy model that looks like this:
class MyModel(meta.Base)
extra_data = Column(postgresql.JSON, nullable=False)
The following (I believe, but I have not run it) works. It ...
0
votes
0
answers
36
views
SQLAlchemy create_all() does not add new columns to existing SQLite tables [duplicate]
I added a new column to an existing SQLAlchemy ORM model in an SQLite-backed application.
My model:
class User(Base):
__tablename__ = "users"
id = Column(String(36), primary_key=True)...
Advice
0
votes
0
replies
49
views
Imports/ general setup flask bootstrap (models, routes, forms, __init__, config, myapp)
This is what I use, let me know if I should tweak anything 👌
routes:
from app import app, db
from flask import render_template, redirect, url_for, request, flash
import sqlalchemy as sa
from app....
0
votes
0
answers
62
views
How use event 'after_bulk_update' in @event.listens_for() for sqlalchemy?
I try use SQL event "before_update" but it is not have reaction for method update(). I need "after_bulk_update" but it not have reaction on update() in my code too. I won't clear ...
3
votes
1
answer
171
views
How to make tables with relationships in SQLAlchemy in different files
I have many-to-many connection in my database and trying to make tables with ORM. Now I have 3 tables (one is secondary)
class TableA(Base):
__tablename__ = "tablea"
id: Mapped[int] =...