Skip to content

Tag: sqlalchemy

How to use JOIN and SELECT AS together in SQLAlchemy?

I have the two following tables. Users Table id name email 32 Hello e@mail.com 23 World p@mail.com Sales Table id SellerId CustomerId Amount 4 32 23 25 I want to join the tables in the following way to get this result. Here I want to only get the entries where customer id is equal to 23. Id SellerId SellerNam…

Bulk Saving and Updating while returning IDs

So I’m using sqlalchemy for a project I’m working on. I’ve got an issue where I will eventually have thousands of records that need to be saved every hour. These records may be inserted or updated. I’ve been using bulk_save_objects for this and it’s worked great. However now I ha…

Bound metadata RemovedIn20Warning in debug mode

I use SQLAlchemy 1.4.0beta1 and enabled future flag for both the engine and the Session. Normally I don’t receive warnings. But in debug mode I receive warnings on 2.0 style select statements. My models.py: Code with warning: Warning itself: Why is there any warning if I don’t bind any MetaData an…

Why am I getting AmbiguousForeignKeysError?

I’ve run into an issue after following the SqlAlchemy guide here. Given the following simplified module: That I am attempting to build a query using: Why am I getting the following error? I was pretty sure I’d specified the two foreign key relationships? Update: I’ve tried the following comb…