Skip to content
Advertisement

Tag: postgresql

How to fix IntegrityError: (psycopg2.errors.ForeignKeyViolation) update or delete on table “users” violates foreign key constraint

I have two tables created with Flask-SQLAlchemy below – they have a one to one relationship. I would like to update the user table in a case when the user would like to have a new username: The db.session.commit throws the following error: The error says the logo table still has the old username but I have updated it and

Trying to supply PGPASS to Docker Image

New to Docker here. I’m trying to create a basic Dockerfile where I run a python script that runs some queries in postgres through psycopg2. I currently have a pgpass file setup in my environment variables so that I can run these tools without supplying a password in the code. I’m trying to replicate this in Docker. I have windows

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:

AWS Aurora: bulk upsert of records using pre-formed SQL Statements

Is there a way of doing a batch insert/update of records into AWS Aurora using “pre-formed” Postgresql statements, using Python? My scenario: I have an AWS lambda that receives data changes (insert/modify/remove) from DynamoDB via Kinesis, which then needs to apply them to an instance of Postgres in AWS Aurora. All I’ve managed to find doing an Internet search is

Advertisement