Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [sqlalchemy]

SQLAlchemy is a Python SQL toolkit and Object Relational Mapper that gives application developers the full power and flexibility of SQL.

sqlalchemy
0 votes
0 answers
22 views

Problem with circular Relashionship in async SQLAlchemy

I have the following sqlalchemy structure for some objects: from typing import Optional from sqlalchemy import ForeignKey, Integer from sqlalchemy.orm import DeclarativeBase, mapped_column, ...
Кирилл Сыроежкин's user avatar
0 votes
0 answers
19 views

sqlalchemy - `validates` on a Relationship does not emit on assignment event

Consider the following using sqlalchemy: from sqlalchemy.orm import validates class DeviceTestResult: __tablename__ = "device_test" passed: bool = mapped_column(default=False, init=...
frimann's user avatar
0 votes
0 answers
10 views

SQLAlchemy-Utils Aggregated Attributes: How to apply filter before aggregating to create an aggregated field?

from sqlalchemy_utils import aggregated class Thread(Base): __tablename__ = 'thread' id = sa.Column(sa.Integer, primary_key=True) name = sa.Column(sa.Unicode(255)) @aggregated('...
Howard S's user avatar
  • 141
-1 votes
0 answers
21 views

How do I reuse columns between tables in SQLAlchemy 2?

I have some very common columns I'd like to share between different tables, but no special relationships between them. For example "created_at". I think the right approach is concrete table ...
lorg's user avatar
  • 1,158
0 votes
0 answers
38 views

Sporadic failures in FastAPI SQLAlchemy deployment due to database connection errors

Our FastAPI deployment uses SQLAlchemy to connect to our database and fetch/filter metadata, but it is proving very flakey. Load balancing tests using Locust show a very odd behavior where initial ...
Adam's user avatar
  • 23
0 votes
0 answers
25 views

Problems Sending Data From Python to MySQL [duplicate]

I’m having problems with the connector engine from SQLAlchemy connecting to MySQL. The database and table I want to insert into are already created in MySQL. I keep getting an AttributeError: ‘Engine’ ...
Bryan Hawkshaw's user avatar
0 votes
0 answers
24 views

Alembic generates all models at revision

I am trying to run alembic on a database where there are about 20 tables that are created by sqlalchemy models. I am using 5 schemas to keep the tables separate from each other. When I run alembic ...
AnGeLL1337's user avatar
-1 votes
1 answer
34 views

Why does Sqlalchemy cleanup query results if query is not in constructor? [closed]

I've created a class Result that takes an sqlalchemy statement, stores the statement, executes the statement, and stores the execution results. If the statement is executed directly in __init__(), the ...
UndoingTech's user avatar
0 votes
1 answer
35 views

Mapper "NoReferencedTableError" exception when trying to implement many-to-many ORM data model with SQLAclhemy+Flask

I'm volunteering for a small local community's project while learning Python at the same time. It's first time with Flask and SQLAlchemy for me (MySQL is used to store the data). ORM I chose was ...
tis's user avatar
  • 123
1 vote
0 answers
26 views

@event.listens_for() didnt work with endpoint

"I need to delete cache by key, which I could get from a remote object endpoint of FastAPI. In the documentation, I read that I can use event.listens_for with a parameter to track the table from ...
1 vote
0 answers
36 views

SQLAlchemy difference between regular query and text

I am trying to insert new rows in a table that might already exist with constant values given from my application. I have tried to create the following code: with engine.begin() as con: con....
Port's user avatar
  • 131
0 votes
0 answers
14 views

SQLalchemy and Langchain: How to select a specific table?

I am new to data engineering and I'm trying to use the sql agent in Langchain but I cannot seem to ingest the sql table correctly. Basically, I connect to the server, but I need to execute something ...
Lisa's user avatar
  • 3
0 votes
0 answers
15 views

SQLAlchemy: AssociationProxy/HybridProperty returning a list of unique elements of proxied list

Considering the following MRE: from sqlalchemy import ForeignKey from sqlalchemy.orm import DeclarativeBase from sqlalchemy.orm import Mapped from sqlalchemy.orm import mapped_column from sqlalchemy....
Moley's user avatar
  • 33
-1 votes
2 answers
39 views

sqlalchemy - dataclass with auto incrementing primary key

I'm using sqlalchemy to map database objects to Python dataclasses. I have a class with the primary key id. from sqlalchemy.orm import Mapped, mapped_column, relationship, registry __reg = registry() ...
frimann's user avatar
0 votes
0 answers
24 views

How to elegantly combine complex Python object and SQLAlchemy object model classes?

I have a rather complex class with complex properties computed from a provided df to init and these properties may be other class types that can be eventually serialized into a string. In Python I ...
Stevie's user avatar
  • 366

15 30 50 per page
1
2 3 4 5
1578