SQLAlchemy: cascade delete
I must be missing something trivial with SQLAlchemy’s cascade options because I cannot get a simple cascade delete to operate correctly — if a parent element is a deleted, the children persist, with null foreign keys.
I must be missing something trivial with SQLAlchemy’s cascade options because I cannot get a simple cascade delete to operate correctly — if a parent element is a deleted, the children persist, with null foreign keys.
I’m starting a new application and looking at using an ORM — in particular, SQLAlchemy.
I want to query services between two dates and sum their prices. When I try to use func.sum with Services.query, I get TypeError: BaseQuery object is not callable. How do I query using a function with Flask-SQLAlchemy?
How can I use ORDER BY descending in a SQLAlchemy query like the following?
class Parent(db.Model): id = db.Column(db.Integer, primary_key=True) class Child(db.Model): id = db.Column(db.Integer, primary_key=True) parent_id = db.Column(db.Integer, db.ForeignKey('parent.id')) parent = Parent() db.session.add(parent) child = Child() child.parent_id = parent.id db.session.add(child) db.session.commit() I want to INSERT into both parent and child tables inside a session considering that the parent_id must be included in the child table. In the moment … Read more
I have a query which looks like this:
I need to alter data during an Alembic upgrade.
When I try SQLAlchemy Relation Example following this guide: Basic Relationship Patterns
Am trying to setup a postgresql table that has two foreign keys that point to the same primary key in another table.
I am trying to get an collection of objects out of a database and pass it to another process that is not connected to the database. My code looks like the one below but I keep getting: