Psycopg2 using wildcard causes TypeError

Currently I am attempting to search a database to grab certain events. My query is as such SELECT * FROM events WHERE summary ILIKE E'%test%' AND start_time > '2010-10-01' Simply put I need the...

Copy cursor object in Python

I am working on a Trac-Plugin... To retrieve my data I create a cursor object and get the result table like this: db = self.env.get_db_cnx() cursor = db.cursor() cursor.execute("SELECT...")...

uWSGI, Flask, sqlalchemy, and postgres: SSL error: decryption failed or bad record mac

I'm trying to setup an application webserver using uWSGI + Nginx, which runs a Flask application using SQLAlchemy to communicate to a Postgres database. When I make requests to the webserver,...

Cursors with postgres, where is the data stored and how many calls to the DB

Hi I am using psycopg2 for postgres access. I am trying to understand where "cursor" stores the returned rows. Does it store it in the database as a temporary table or is it on the clients...

Error Installing Psycopg2 on MacOS 10.9.5

I'm trying to install Psycopg2 on my Macbook, but I am getting an error. I found a lot of the same questions on StackOverflow but no answer seems to work. I'm using: OS: MacOS 10.9.5 Python...

How to set connection timeout in SQLAlchemy

I'm trying to figure out how to set the connection timeout in create_engine(), so far I've tried: create_engine(url, timeout=10) TypeError: Invalid argument(s) 'timeout' sent to...

Django can't drop database: psycopg2.OperationalError: cannot drop the currently open database

Whenever I try to run my Django tests via manage.py, the tests run fine however at the end when Django is destroying the database the following error occurs: Destroying test database for alias...

Detect whether to fetch from psycopg2 cursor or not?

Let's say if I execute the following command. insert into hello (username) values ('me') and I ran like cursor.fetchall() I get the following error psycopg2.ProgrammingError: no results to...

Alembic's server_default and Postgres

I would like to run a migration using alembic from a sqlalchemy model to another. The initial model looks like this: from sqlalchemy.dialects.postgresql import JSONB from sqlalchemy_utils import...

docker-compose/django TypeError: expected str, bytes or os.PathLike object, not NoneType

I'm trying to set up my Django and postgres dev environment with docker so I can run it on other machines more easily as well as run everything from 1 terminal window (I'll be adding my react...

Python: why do I get an error when I import geopandas?

I try to import geopandas in my jupyter notebook. import geopandas as gp and I get the following error: ImportError:...

how flask-sqlalchemy turn off returning id while insert data

I'm trying to insert data to PostgreSQL 8.3.23 by Flask-SQLAlchemy==2.3.2, the errors show that INSERT statement is not supported in this version of Greenplum Database. so how can I turn off...

How to use psycopg2-binary in Python?

I installed the psycopg2-binary package using pip install psycopg2-binary. But when how can I use it in Python? import psycopg2 as pg2 conn = pg2.connect(database = 'dvdrental', user = 'postgres',...

Failed to install gcc on Python-3.7-alpine docker container

I am trying to set up a Python docker container, when I run the command "docker-compose up" to build the Dockerfile it throws me this error message below. The docker file was successfully built...

"psycopg2.errors.UndefinedTable: relation "flights" does not exist"

import os from sqlalchemy import create_engine from sqlalchemy.orm import scoped_session, sessionmaker engine = create_engine("postgres://kali:[email protected]/mydb") db =...

Automatically populate SQL column based on foreign key constraint

Table 1: parent_id string_id 5001 a 8759 b 3957 c string_id is the primary key for Table 1. parent_id has an UNIQUE constraint on it. Table 2: child_id parent_id string_id 1 ...

Query works fine in psql , but Django cursor.execute() gives "cannot extract elements from a scalar"

I've got a large query which I need to run manually on a postgres DB from within Django. When I run the query manually in psql I have no problems, but when I run it using cursor.execute() in...

Problems instaling libpq-dev in ubuntu 20.04

I am currently trying to install libpq-dev to install psycopg2. The problem is, when I try to install it, an error occurs saying I don't have the latest libpq5 version. However when I try to...

How to solve libpq.so.5 Import error when running postgresql on alpine in docker

Hi I am trying to run postgresql in alpine in docker with SQLAlchemy and flask but anytime I run my app I get this error ImportError: Error loading shared library libpq.so.5: No such file or...

ERROR: Failed building wheel for psycopg2 (Ubuntu 20.04 + Python 3.8.5 + venv)

Greetings wisdom from Stackoverflow! I'm having issues building wheel for psycopg2 thru pip install -r requirements.txt. I'm on ubuntu 20.04 + python 3.8.5 + venv. This is my...

Using apache-airflow-providers-snowflake on airflow (no module named Snowflake)

I have installed package apache-airflow-providers-snowflake on airflow on docker and i am getting error No module named Snowflake Please refer attachment (check the error mentioned for the...

How to access Postgresql database from multiple threads in a Django test?

I have a Django website with a PostgreSQL database that runs some background tasks with multithreading. However, I am having troubles testing this multithreading part. I followed...

Cannot install psycopg2 with pip3 on M1 Mac

I cannot install psycopg2 on my M1 Mac and I used pip3. When I tried to install with pip3 install psycopg2 The output like that: ERROR: Command errored out with exit status 1: command:...

Resolve django test RuntimeError on channels/async testcases

I'm trying to write a testcase for my django (3.2) channels consumer to implement websocket communication. I've managed to get the testcase to pass, but now it seems that the testcase teardown...

Trouble with pip install psycopg2

Trying to learn Django. Followed the tutorial and created my virtual environment. Now I'm trying to install psycopg2. I can install psycopg2-binary, but I've been told for "psycopg2-binary is good...

from Google import Create_Service ModuleNotFoundError: No module named 'Google'

I'm trying to use Gmail api in python to send email but I cant get past importing the Google module despite using "pip install --upgrade google-api-python-client" or "pip install google". However...

Python psycopg2 SCRAM authentication

I'm trying to run a python application that uses psycopg2-binary==2.9.1, but I'm hitting this error: psycopg2.OperationalError: SCRAM authentication requires libpq version 10 or above When I...

Unable to run Django with PostgreSQL in Docker

I wanted to set up a Django app with PostgresDb inside docker containers so that's why I wanted to setup docker-compose but when I execute my code docker, django and db all are working fine and I...

Python find a string with single quote symbol in postgresql table

I need to look up for a string that contains multiple single quotes from my psql table. My current solution is replacing the single quotes with double single quotes like this: sql_query =...

Psycopg2 on AWS Lambda not connecting to RDS database

When I try to connect to my RDS Postgresql DB I get the following output { "errorMessage": "2022-01-07T13:28:35.428Z 975a92cd-936c-4d1c-8c23-6318cd609bff Task timed out after 10.01...