psycopg2 Questions
2
Solved
I would like to put a button on the GUI if the software connects to a specific Postgre-DB. I wrote a small test-function: if it can connect to the DB it returns True, if not it returns False.
The...
Gentlewoman asked 30/1, 2017 at 15:46
3
Solved
I'm running PostgreSQL 9.6 (in Docker, using the postgres:9.6.13 image) and psycopg2 2.8.2.
My PostgreSQL server (local) hosts two databases. My goal is to create materialized views in one of the ...
Secrest asked 24/5, 2019 at 9:39
1
Solved
We just transitioned to using Docker for development and are using the ubuntu:18.04 image. We noticed that queries using psycopg2 failed after a few minutes. This answer solved the problem using th...
Scent asked 3/3, 2022 at 20:8
3
Solved
When specifying a parameter to execute() in psycopg2 in Python, like this:
cursor.execute('SELECT * FROM %s', ("my_table", ))
I'm getting this error:
psycopg2.ProgrammingError: syntax error at ...
Defamation asked 19/2, 2012 at 23:28
2
I have a stored procedure in Postgres called sales, and it works well from pgadmin:
CALL sales();
However, when I call it from Python:
import psycopg2
conn = psycopg2.connect (host ....)
cur = con...
Koto asked 5/3, 2019 at 9:55
4
Solved
I need to export some rows from a table in a PostgreSQL database to a .csv file using a Python script:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys, psycopg2
...
conn = psycopg2.connec...
Debra asked 2/4, 2018 at 12:0
7
Solved
I'm trying execute a simple query, but getting this error no matter how I pass the parameters.
Here is the query (I'm using Trac db object to connect to a DB):
cursor.execute("""SELECT name...
3
Solved
cur.execute("SELECT \
title, \
body, \
date \ # This pgsql type is date
FROM \
table \
WHERE id = '%s';", id)
response = cur.fetchall()
print response
As an example this gives me: -
[('s...
3
Solved
I am using the django ORM with a postgres database. A small group of users interact with it using import and export scripts. The database is only available on our intranet. If someone tries to use ...
Aida asked 25/9, 2011 at 20:15
6
Solved
I am using psycopg2 module in python to read from postgres database, I need to some operation on all rows in a column, that has more than 1 million rows.
I would like to know would cur.fetchall() ...
Stethoscope asked 29/7, 2013 at 20:14
2
Solved
I am working on a project where I am using psycopg2 connection to fetch the data from the database like this,
cursor = connection.execute("select * from table")
cursor.fetchall()
Now aft...
Uncivil asked 28/1, 2022 at 10:23
3
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 'de...
Triple asked 21/5, 2016 at 20:32
1
Solved
I have a procedure that returns a recordset using the cursor method:
CREATE OR REPLACE PROCEDURE myschema.permissions_sp(rs_out INOUT refcursor)
LANGUAGE plpgsql
SECURITY DEFINER
AS $$
BEGIN
OPE...
Jeane asked 24/12, 2021 at 16:21
2
I'm writing some integration tests for a web API I build using Django Rest Framework and Django 1.11. My tests are passing when I use DRF's APIClient to send requests to my API endpoints, but when ...
Pernick asked 13/4, 2018 at 15:7
7
Solved
I have a dataframe in Python. Can I write this data to Redshift as a new table?
I have successfully created a db connection to Redshift and am able to execute simple sql queries.
Now I need to writ...
Tasso asked 15/7, 2016 at 18:33
11
Solved
Trying to get a server ready for a django project and I'm running into some issues with setup for postgres.
I'm following this guide:
https://jee-appy.blogspot.com/2017/01/deply-django-with-nginx....
Derril asked 15/11, 2017 at 22:14
25
I run
sudo pip install psycopg2
and I get a bunch of output that looks like:
cc -DNDEBUG -g -fwrapv -Os .....
.....
cc -DNDEBUG -g -fwrapv -Os .....
.....
And at the end it says:
ld: libra...
Phoney asked 9/10, 2014 at 21:17
3
Solved
I have a Django project that I would like to use with a PostgreSQL database but I am having an issue with psycopg2. When I try to run the dev server or perform a syncdb I get this error. My project...
Dessalines asked 11/6, 2014 at 7:57
1
I have a problem with psycopg2. It fails to perform some queries. I have traced exceptions and it says: django.db.utils.InterfaceError: cursor already closed
I have already seen some similar cases ...
Elin asked 30/1, 2021 at 14:34
0
So i have a composite field that i want to use in my django models using postgres as the DB.
CREATE TYPE address_verbose AS (
contact_person_name string_not_null,
mobile string_no_spaces,
mobil...
Oxymoron asked 18/11, 2021 at 6:21
2
I have the new (2021) Macbook Air running the Apple M1 chip. I have set up my django application, which uses postgresql, and I have created a virtualenv running Python 3.9.2. Have installed Python ...
Scotfree asked 24/3, 2021 at 8:42
2
Solved
I'm using PostgreSQL 9.3.3 on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-52), 64-bit.
I've done
psycopg2.connect
, got the cursor and can run lines of code si...
Swordcraft asked 8/1, 2015 at 3:8
4
I have a postgres database with the timescaledb extension.
My primary index is a timestamp, and I would like to select the latest row.
If I happen to know the latest row happened after a certain ...
Beak asked 28/7, 2018 at 20:25
4
Solved
I have a dataframe with the dtypes shown below and I want to insert the dataframe into a postgres DB but it fails due to error can't adapt type 'numpy.int64'
id_code int64
sector object
created_da...
4
Solved
I have an SQL statement which contains a subquery embedded in an ARRAY() like so:
SELECT foo, ARRAY(SELECT x from y) AS bar ...
The query works fine, however in the psycopg2 results cursor the a...
Antonetteantoni asked 28/5, 2013 at 17:10
© 2022 - 2024 — McMap. All rights reserved.