Skip to content
Advertisement

Tag: psycopg2

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 Version: 3.4.3 My error code is: Answer I ran pip install psycopg2-binary and it worked like charm More info about the binary package Python

Installing psycopg2 in a virtualenv in ubuntu os

I using a virtualenv and I am trying to set up postgresql. I have psycopg2 installed on my system, but it appears that my virtual env does not recognize psycopg2. Is it possible to just copy the system wide psycopg2 files into my django project directory or is this a bad approach to take? This is the relevant part of

query from postgresql using python as dictionary

I’m using Python 2.7 and postgresql 9.1. Trying to get dictionary from query, I’ve tried the code as described here: http://wiki.postgresql.org/wiki/Using_psycopg2_with_PostgreSQL It is printing the next answer: printing the item itself, show me that it is list. The excepted answer was dictionary. Edit: Trying the next: returns Answer If you don’t want to use a psycopg2.extras.DictCursor you can create a

Get psycopg2 count(*) number of results

Whats the correct way to get the number or rows returned by this query? I’m specifically looking to see if no results are returned. Thanks. Answer results is itself a row object, in your case (judging by the claimed print output), a dictionary (you probably configured a dict-like cursor subclass); simply access the count key: Because you used .fetchone() only

Making sure that psycopg2 database connection alive

I have a python application that opens a database connection that can hang online for an hours, but sometimes the database server reboots and while python still have the connection it won’t work with OperationalError exception. So I’m looking for any reliable method to “ping” the database and know that connection is alive. I’ve checked a psycopg2 documentation but can’t

Advertisement