Skip to content
Advertisement

Tag: sqlalchemy

PostgreSQL NOT operator in SQLAlchemy

I’d like to achieve toggling a boolean flag with just one query. My query looks as follows: Does SQLAlchemy supports PostgreSQL NOT (https://www.postgresql.org/docs/current/functions-logical.html) operator. How this can be achieved different way? Answer As Adrian Klaver points out in their comment, SQLAlchemy’s not_ operator will toggle the values. All of these statements are equivalent: Will generate this SQL:

Can’t Query and iterate through database

I am trying to filter only the rows that have the foreign id of 1 or in this case ‘Skincare’ I have tried both, but no matter what combo I try it either applies no filter, nothing at all shows up, or I get an error that it is not iterable. I want Answer I’m not sure what is going

How to filter after two joins in flask SQL alchemy

I have the following 3 tables: Each sample has a chain of processes it goes through and I need to get a table which includes both Sample.id and the latest date it has encountered a process, so that I can filter by this date. Something like this What I tried so far was looking at this and similar solutions: https://blog.miguelgrinberg.com/post/nested-queries-with-sqlalchemy-orm

Packet sequence number wrong – got 1 expected 0

Getting the below error in MariaDb and its causing timeout issue : Debugged it with removing skip-name-resolve, granting privileges to user@localhost, and in pyton create_engine used pool_pre_ping = True and pool_recycle=3600 but nothing seems to solve the issue. MariaDb version is 10.4.20 and Python is 3.9.Its not a multithreaded application as well. Any pointers on solving debugging this issue would

SQLAlchemy changes value after commit

Seemingly out of nowhere, my Flask app is now inserting the same value for one column in a table in my database no matter what when it had been previously working. I have a model here: and code in my application: The result of the prints is So it looks like after the record is committed, the number changes and

Flask-SQLAlchemy Error – AttributeError: ‘NoneType’ object has no attribute ‘append’

Below I have defined SQLAlchemy models for a table containing companies and a table containing contracts. Each company can have many contracts while each contract can belong to one company (one to many relationship). This relationship is modelled by contracts = db.relationship(‘ContractModel’, backref=db.backref(‘company’, lazy=True)). Models: I try to append a company to a contract (which links them) after creating a

function object has no attribute ‘connect’

Seems there’s a problem with my sql alchemy connection, don’t get why? it works sometimes and then doesn’t the next. Also vs code isn’t auto recommending sql alchemy methods, maybe I’ve set it up wrong? –database.py file main file ERROR I GET: It seems to me that the query method from sql alchemy isnt working for some reason. It doesn’t

Advertisement