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…
Tag: sqlalchemy
Python3 Can’t load plugin: sqlalchemy.dialects:mysql.pymysql
I’m trying to connect to my database with sqlAlchemy and get the error Can’t load plugin: sqlalchemy.dialects:mysql.pymysql. The script worked before and I didn’t change anything, tho I can’t connect to the db. I’m importing the libraries: My connection: sqlAlchemy and pymysql ar…
How to get list of objects from multi-value field with SqlAlchemy using ORM?
I have MS Access DB file (.accdb) from my client and need to describe tables and columns with declarative_base class. As I can see in table constructor – one of column has Integer value and has relationship “one-to-many” with another column in some another table (foreign key). But actually i…
SQLAlchemy require primary key to be generated by program
When defining a table, you define one column as primary_key=True. As shown in the tutorial, SQLAlchemy will automatically create an ID for an item, even when it is not supplied by the user. The primary_key=True also automatically sets nullable=False. Is there a way that I can set up the Primary Key so that it…
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…
SQLAlchemy SSL SYSCALL timeout coping mechanism
I’m using a combination of SQLAlchemy and Postgres. Once every while my database cluster replaces a failing node, circle of life I guess. I was under the impression that by configuring my engine in the following manner: my connections would be timing out on queries >30s, and my connections would time…
How to have the possibility to call name of columns in db.session.query with 2 tables in Flask Python?
I am developing a web application with Flask, Python, SQLAlchemy, and Mysql. I have 2 tables: I need to extract all the tasksusers (from TaskUser) where the id_task is in a specific list of Task ids. For example, all the taskusers where id_task is in (1,2,3,4,5) Once I get the result, I do some stuff and use …
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…
Can’t append to an existing table. Fails silently
I’m trying to dump a pandas DataFrame into an existing Snowflake table (via a jupyter notebook). When I run the code below no errors are raised, but no data is written to the destination SF table (df has ~800 rows). If I check the SF History, I can see that the queries apparently ran without issue: If I…