Skip to main content

All Questions

0 votes
1 answer
38 views

AmbiguousForeignKeysError in SQLAlchemy: Resolving Foreign Key Relationship in Flask Models

I'm facing an issue with SQLAlchemy in my Flask application. I have two models: User and AssignmentReminder. Both models have foreign key relationships with the users.id column in the User model, but ...
user avatar
1 vote
0 answers
83 views

Ancestor foreign keys are not enforced in Oracle DB when inserting data using SQLAlchemy

I have created the SQLAlchemy data model: class AncestorTable(Base): __tablename__ = 'ancestor' id: Mapped[int] = mapped_column(primary_key=True) some_value: Mapped[float] parent: ...
Bartosz's user avatar
  • 11
0 votes
1 answer
101 views

Cascade Delete in SqlAlchemy One-to-Many relationship made without relationships()

In my FastAPI app, I use sqlalchemy. The main goal of the app is that each user is stored in a sqlalchemy table users and can create different contents (25+ different contents). Each content has its ...
Cesar Mry's user avatar
0 votes
0 answers
64 views

Relationship problem with SQLAlchemy and SQLite in Python

I created a db in SQLite and added tables with SQLAlchemy. DB_URL = "sqlite:///wimp.sqlite3" engine = create_engine(DB_URL, echo=True) Session = sessionmaker(autocommit=False, autoflush=...
Marco's user avatar
  • 1
1 vote
1 answer
46 views

Foreign Key is not deleted mapped table's row

I use sqlalchemy with sqlite and aiosqlite driver. I created two tables as the follows: class AccountsModel(Base): __tablename__ = 'accounts' id: Mapped[intpk] email_id: Mapped[int] = ...
bahladamos's user avatar
0 votes
1 answer
771 views

SQL Alchemy Problem : sqlalchemy.exc.InvalidRequestError

the Error i am getting is this one (After tryig to test a GET for the user object, while creating CRUD Endpoint) : sqlalchemy.exc.InvalidRequestError: When initializing mapper Mapper[User(users)], ...
Namba Kenji's user avatar
0 votes
1 answer
66 views

SQLAlchemy: select nested columns

I have following models and associations. AA can have multiple BB i.e AA.bbs is a list of BB. I want to select only few columns from AA and BB i.e name of AA and name, username from BB. ...
StaticName's user avatar
0 votes
1 answer
218 views

How to create ForeignKeyConstraint in SQLAlchemy

I'm trying to temporarily drop a foreign key constraint on a table to run efficient inserts, using SQLAlchemy. I've written the following context manager to handle dropping and recreating: from ...
Roméo Després's user avatar
1 vote
0 answers
75 views

insert and retrieve nested data using foreignkeys with sqlalchemy

I am trying to see if i can use python / sqlalchemy with foreignkeys to create nested tables . Say I have two parent tables A and B that are linked to table C through interger ids as foreignkeys ...
user1573820's user avatar
1 vote
1 answer
315 views

How to implement a "Citation" table? (using SQLModel or SQLAlchemy)

I'm struggling with implementing the concept of "scientific paper citation" in SQL. I have a table of Papers. Each Paper can cite many other Papers and, vice-versa, it can be cited by many ...
ychiucco's user avatar
  • 830
-1 votes
2 answers
450 views

SQLAlchemy cannot find referenced table via foreignkey in many-to-many relationship

I have already succeeded in adding one many-to-many relationship in my database. However, when trying to add another, I am met with: sqlalchemy.exc.NoReferencedTableError: Foreign key associated with ...
Mave's user avatar
  • 103
0 votes
1 answer
112 views

etl-process: from python-dataframe to postgres with SQLAlchemy

I want to create tables in a Postgres database using Python's SQLAlchemy package and insert data from a dataframe into them. I also want to assign foreign keys and primary keys. The following code ...
user20880339's user avatar
3 votes
0 answers
235 views

python flask join two tables and show the result in html

from flask import Flask, render_template from flask_sqlalchemy import SQLAlchemy app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://name:password@localhost/database' app.config['...
Harold Meneley's user avatar
3 votes
1 answer
1k views

Alembic drops and creates foreign key constraints (autogenerate) when the table has different schema than the referenced columns

I am trying to use the autogenerate feature from alembic to update the schema of a MSSQL database. class Table1(Base): __tablename__ = "table1" __table_args__ = ( ...
UnknownError's user avatar
0 votes
1 answer
3k views

SQLAlchemy - how to set relationship to back_populates to parent id in the same table

I try to set fk which parent_id contains id of a person in People table in orm manner and backpopulate between them but it does not work. class People(Base): __tablename__ = "people" ...
THX's user avatar
  • 11

15 30 50 per page
1
2 3 4 5
9