psycopg2

Error: could not determine PostgreSQL version from '10.3' - Django on Heroku

爱⌒轻易说出口 提交于 2019-12-05 09:52:46
问题 I tried to push from local env to Heroku master. No new requirements from the previous commit. However, I received an Error which saying the system could not determine PostgreSQL version from "10.3". Here is my requirements list: amqp==1.4.9 anyjson==0.3.3 appdirs==1.4.3 awscli==1.11.89 billiard==3.3.0.23 boto==2.46.1 botocore==1.5.52 celery==3.1.25 Collectfast==0.5.2 colorama==0.3.7 dj-database-url==0.4.2 Django==1.11.1 django-celery==3.2.1 django-recaptcha==1.3.0 django-redis-cache==1.7.1

change database (postgresql) in python using psycopg2 dynamically

十年热恋 提交于 2019-12-05 08:23:42
Can anybody tell me how can I change database dynamically which I have created just now.. using the following code... I think during the execution of this code I will be in default postgres database (which is template database) and after new database creation I want to change my database at runtime to do further processing... from psycopg2 import connect from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT dbname = 'db_name' con = connect(user ='postgres', host = 'localhost', password = '*****') con.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT) cur = con.cursor() cur.execute('CREATE

Psycopg2 install with pip works but cannot import module on OS X 10.9

不问归期 提交于 2019-12-05 06:32:23
I've installed psycopg2 with pip install psycopg2 and it worked just fine. The install output had a couple of warning along the lines of In file included from ./psycopg/psycopg.h:33: ./psycopg/config.h:71:13: warning: unused function 'Dprintf' [-Wunused-function] static void Dprintf(const char *fmt, ...) {} ^ 1 warning generated. but in the end it says Successfully installed psycopg2 and it also appears when I run pip list . Now when I try to import it in python I get an error: $ python Python 2.7.5 (default, Aug 25 2013, 00:04:04) [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on

How can I use server-side cursors with django and psycopg2?

淺唱寂寞╮ 提交于 2019-12-05 04:06:17
I'm trying to use a server-side curser in psycop2 as detailed in this blog post . In essence, this is achieved with from django.db import connection if connection.connection is None: cursor = connection.cursor() # This is required to populate the connection object properly cursor = connection.connection.cursor(name='gigantic_cursor') When I execute the query: cursor.execute('SELECT * FROM %s WHERE foreign_id=%s' % (table_name, id)) I get a ProgrammingError : psycopg2.ProgrammingError: can't use a named cursor outside of transactions I've naively tried to create a transaction using cursor

psycopg2 can't see my PostgreSQL instance

爷,独闯天下 提交于 2019-12-05 03:55:13
问题 I'm on Windows, with a 32bit install of python 2.6.6 and psycopg2. When psycopg2 tries to connect, it gets an OperationalError : Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import psycopg2 >>> conn = psycopg2.connect("dbname=your_database user=postgres password=xxxx host=127.0.0.1:5432") Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Python26

Installing psycopg2 fails on MacOS with unclear error message

喜夏-厌秋 提交于 2019-12-05 01:34:33
问题 Trying to install psycopg2 using pip 19.1 on MacOS 10.14.4 returns the lengthy error message below. I understand there are warnings related to gcc, but given the actual error messages I cannot find any clues what the underlying problem is. I have tried the following actions without any luck: Upgraded Xcode to the latest version (10.2.1) Upgrade Postgresql to 11.2.1 Uninstalled psycopg2-binary to prevent any dependency issues Cleared all files left by a previously successful install at

There is no South database module 'south.db.postgresql_psycopg2' for your database django

我怕爱的太早我们不能终老 提交于 2019-12-05 01:25:30
I have a django app with version as 1.6.5 , i am trying to upgrade it to 1.8 , but on the way i got the below error right after the django version was increased to 1.8 There is no South database module 'south.db.postgresql_psycopg2' for your database. Please either choose a supported database, check for SOUTH_DATABASE_ADAPTER[S] settings, or remove South from INSTALLED_APPS. Code INSTALLED_APPS = [ 'django_messages', 'avatar', 'tinymce', 'south', 'tracking', ...... ] DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'HOST': '127.0.0.1', 'NAME': 'xxxxxx', 'USER':

Get warning messages through psycopg2

喜夏-厌秋 提交于 2019-12-05 00:49:36
I want to call a plpgsql function through psycopg2 and see the warning messages. I.e, I have this function: create or replace function test_warning() returns void as $$ begin raise warning 'this is only a test'; end; $$ language plpgsql; and call it so in python: import psycopg2 conn = psycopg2.connect(conn_string) cursor = conn.cursor() cursor.callproc("test_warning") # or so: cursor.execute('SELECT test_warning()') Unfortunately the warning message as defined in plpgsql does not appear anywhere in the python output. Is there a way to get the warning message printed in the python output? The

Is it required to close a Psycopg2 connection at the end of a script?

旧巷老猫 提交于 2019-12-05 00:23:40
What are the consequences of not closing a psycopg2 connection at the end of a Python script? For example, consider the following snippet: import psycopg2 psycopg2.connect("dbname=test") The script opens a connection, but does not close it at the end. Is the connection still open at the end of the execution? If so, is there an issue with not closing the connection? Normally when your python program exits, all the sockets it owns will be closed, and open transactions aborts. But it's good practice to close the connection at the very end. Closing a connection as soon as you don't need it anymore

Opening a postgres connection in psycopg2 causes python to crash

非 Y 不嫁゛ 提交于 2019-12-04 23:53:40
问题 I'm getting the following error message when I try to open up a connection to a postgres database. Perhaps it's related to OpenSSL, but I can't understand the error message. Can anyone help? >>> import psycopg2 >>> conn = psycopg2.connect(host = '', port = , dbname = '', user = '', password = '') Auto configuration failed 12848:error:02001015:system library:fopen:Is a directory:.\crypto\bio\bss_file.c :169:fopen('D:/Build/OpenSSL/openssl-1.0.1h-vc9-x64/ssl/openssl.cnf','rb') 12848:error