1
vote
1answer
51 views

Postgresql: Query 10x slower in a different client

Looking at the postgres server log, I see that the exact same query on the same postgres server takes much longer (about 10x longer) when invoked from a Linux client or from a Windows client. The ...
0
votes
1answer
25 views

handle crash of flask app on database restart

Currently have made a flask application which crashes when I do a postgres database restart, because the cursor which was opened is stale ... How do I handle this situation. Currently connecting the ...
0
votes
1answer
25 views

Django resetting Postgres connection

I'm running Django 1.4 and using psycopg2 along with Postgres 9.2.4. In my Postgres logs 2013-05-30 16:20:22 UTC LOG: could not receive data from client: Connection reset by peer Below is the ...
1
vote
2answers
37 views

Return Posgresql uuid array as list with psycopg2

I have an SQL statement which has a subquery in an ARRAY(): SELECT foo, ARRAY(SELECT x from y) as bar ... The query works fine, but in the psycopg2 results cursor ARRAY is a string '{1,2,3}', not a ...
-1
votes
0answers
34 views

psycopg2.OperationalError: FATAL: role “david” does not exist but the role does exist

I installed PostgreSQL on Ubuntu 64bit OS. Then, I created a database called 'l2s' and created a user called 'david' with password 'password'. I wrote a python program to using psycopg2 to connect to ...
0
votes
1answer
36 views

Deployment issues of Psycopg2 Python App

I have created an application in Python that is tested and runs perfectly on my computer (Mac OSX 10.8.3 Python2.7.3 Postgresql9.2.4 Psycopg2-2.5). The app is compiled using py2app, and I can see that ...
-1
votes
1answer
27 views

python psycopg2 ConnectionError: Transaction failed, failure was 'int' object does not support indexing

I am using, python psycopg2 to connect to PostGreSQL and fetching some data on based on timestamp. create_date is defined as below: create_date | timestamp without time zone | not null My query is ...
0
votes
1answer
35 views

“ProgrammingError: syntax error at or near” when executing query in python using psycopg2

I am running Python v 2.7 and psycopg2 v 2.5 I have a postgresql database function that returns a sql query as a text field. I am using the following code to call the function and extract the query ...
0
votes
1answer
37 views

How to write/overwrite a file with HTMLParser

I need to create some files from a template. I'm using psycopg2 to fetch from a database. Then I loop through. Now I need to write to file. Thanks! import sys from HTMLParser import HTMLParser from ...
1
vote
1answer
42 views

Multiple insert statements failing postgresql / psycopg2

I'm using scrapy to scrape a webpage which I then add to a postgres database. The first INSERT statements works fine, and I can select the items from the database. The second one seems to insert data ...
1
vote
4answers
186 views

Psycopg2 image not found

Trying to setup postgres with the postgres mac app and hit this error, which I haven't been able to solve. Any thoughts? ImportError: ...
0
votes
2answers
40 views

psycopg2 psycopg2.InternalError dependent objects

I am using peewee on heroku, but according to peewee docs, dropping related tables has to be done in code. Question is how? I have the following models class WebPage(Model): title = CharField() ...
0
votes
1answer
89 views

Problems in connecting to MusicBrainz database using psycopg2

I am trying to connect to the MusicBrainz database using the psycopg2 python's module. I have followed the instructions presented on http://musicbrainz.org/doc/MusicBrainz_Server/Setup, but I cannot ...
1
vote
1answer
78 views

Python/PostgreSQL - check if server is running

I've just started using the psycopg2 module to access a local PostgreSQL server and I'll like a way to progammatically check if the server is already started so my program can handle the error when I ...
1
vote
2answers
609 views

Django setting : psycopg2.OperationalError: FATAL: Peer authentication failed for user “indivo”

I am getting problem in Django project setting with POSTGRESQL. Here is my setting.py database setting DATABASES = { 'default':{ 'ENGINE':'django.db.backends.postgresql_psycopg2', # ...
0
votes
2answers
78 views

Remove all data from table but last N entries

I'm using psycopg2 with Python. I'd like to periodically flush data from my db. I've set up a task with Timer for this. I had asked this question before, but using the answer listed there freezes ...
0
votes
1answer
35 views

find data that corresponds to newest entry

I'm working on a db via psycopg2, and I want to find the 'newest' entry in the database. It doesn't seem that I should have to do any sorting to obtain this, as I literally just want the newest. The ...
0
votes
1answer
45 views

python PostgreSQL unit test not completing execution

I have unit test as class TestUser(TestCase): def setUp(self): print 'setting db up' db.create_all() def test_new_user(self): user = User('[email protected]', ...
2
votes
2answers
32 views

Ident connection fails via psycopg2 but works via command line

When I try to connect to my postgres server via psycopg2 with a bit of code like this (running python as "username"): psycopg2.connect(database="apis_master") I get an error ...
2
votes
1answer
142 views

Setting application_name on Postgres/SQLAlchemy

Looking at the output of select * from pg_stat_activity;, I see a column called application_name, described here. I see psql sets this value correctly (to psql...), but my application code ...
1
vote
1answer
95 views

Django Postgres psycopg2 wrong script generated - quoting of table names

Django 1.5 PostgreSQL 9.2 psycopg2 2.4.6 I'm using extra feature from QuerySet API to be able to employ functions from cube extension for Postgres - I know that extra is not very good for portability ...
0
votes
1answer
37 views

psycopg2 enum types

I have the following type in postgres 9.2: CREATE TYPE profile_categories AS ENUM ( 'particulier', 'professionel', 'assureur', 'manager' ); So I want to register it with : ...
0
votes
1answer
72 views

Can a pickled object be reliably encoded as Postgres string (to be sent with NOTIFY)?

Postgres NOTIFY supports only string literals (no binary data). I've managed to use it with a pickled object in a following way: message = cPickle.dumps(objectFoo) cursor = connection.cursor() # this ...
0
votes
1answer
91 views

Socket connection to postgres is not close when network down or hard boot the server

I am creating connection with postgresql using sqlalchemy and executing simple command. >>> from sqlalchemy import create_engine >>> c = ...
0
votes
0answers
49 views

psycopg2 difficuty in formatting an array of user defined types in calling postgres stored function [duplicate]

I am using postgres 9.1 and python 2.7 with psycopg2. I have a user-defined type, as CREATE TYPE RegCompT AS (short_name VARCHAR, description VARCHAR, currency CHAR(3), NumId INTEGER); CREATE OR ...
1
vote
1answer
133 views

How to generate a new table in PostgreSQL by iterating over an existing table of OSM data

I have a PostgreSQL database made up of the OSM map data for London. I imported this data using osm2psql. I would like to: Iterate over every line in the planet_osm_line table Break up the lines ...
0
votes
1answer
79 views

Using \o command within a script

Is there a way I can use the \o command from with in psycopg2. If not, is there any way I can automate this command. I am trying to include this command in a script and am not sure how to do it. I ...
0
votes
1answer
43 views

& converted to AND in python using psycopg2 [closed]

I have a character field in a Postgres database with an & in it. When I pull it into some python code (using psycopg2) the data has been converted to 'AND' e.g. 'CASH & CARRY' (in postgres ...
1
vote
2answers
79 views

Execute query many times with IN large array

I'm current writing an application that has to execute the same query many times. The query has a (potentially large) array as parameter, and looks like: SELECT m.a, SUM(m.b) as b, SUM(m.c) as c, ...
0
votes
1answer
193 views

Django 1.4 syncdb + psycopg fails with Timezone Error

After installing Postgres.app on MacOS, and initialising a python virtualenv with Django, dj-database-url, and psycopg2 I repeatedly got: ...
0
votes
1answer
90 views

Specify the connection_factory to SQLAlchemy's create_engine()

I have a custom connection factory class (which inherits from psycopg2.extensions.connection) that I would like SQLAlchemy to use. From the create_engine() documentation, **kwargs takes a wide ...
0
votes
1answer
109 views

cx_freeze fails to import psycopg2 shared lib at runtime

I have built an executable using cxfreeze (inside a python3.2 virtualenv) on my local machine. The executable runs correctly on the local machine. I'm trying to run the executable on a separate ...
0
votes
2answers
173 views

Puzzling encoding inconsistency with python, Flask, psycopg2

I am using postgres with a psycopg2 python/flask web app. I am having an encoding problem that I'm sure is something stupid I'm missing (I'm new to programming). The following statement works ...
3
votes
3answers
244 views

Python psycopg2 - Logging events

I'm using psycopg2, and I have a problem with logging events(executed queries, notifications, errors) to a file. I want to get effect like in PgAdmin history window. For example I'm executing this ...
1
vote
1answer
90 views

Fill pytable using SQL query

I would like to use a dataset equivalent in Python. I want to fill a dataset with data using psycopg2's cursor.fetchall() and then all future queries from this dataset. I have learned that pytables ...
0
votes
1answer
120 views

Psycopg2 Symbol not found: _PQbackendPID Expected in: dynamic lookup

Im getting this error when trying to run python / django after installing psycopg2: Error: dlopen(/Users/macbook/Envs/medint/lib/python2.7/site-packages/psycopg2/_psycopg.so, 2): Symbol not found: ...
1
vote
1answer
131 views

cursor.copy_from failed in postgres

I am facing problems in coping data from one db to another db here is python code. import psycopg2 db = psycopg2.connect("dbname='db' user='xx' password='xx' host='127.0.0.2'") st = db.cursor(); ...
1
vote
1answer
194 views

Copying a table using psycopg2 copy_from and copy_expert?

I want to copy table rows from an old database into a new one using the copy commands available in psycopg2. I thought I could redirect through StringIO like the following io = StringIO.StringIO('') ...
3
votes
1answer
222 views

Django raw SQL query using LIKE on PostgreSQL

I'm trying to do a Raw SELECT in Django using LIKE in the PostgreSQL database with Psycopg2 driver. I've tested pretty much what I've found on the web, but nothing have worked. The situation is the ...
1
vote
2answers
95 views

Python Pyscopg: How do I use place holders with LIMIT/OFFSET and WHERE?

I am currently trying to use place holders in my PostgreSQL query within Python's psycopg's module. Here is a sample of the code I am using. table.execute('SELECT * FROM table WHERE col2 = %s ORDER ...
1
vote
1answer
113 views

Can not “COPY FROM” with Postgres & Python

As the topic, this is the code and there is no error message but data did not get insert. This is my code, and can anyone tell me what's wrong with it? import psycopg2 import sys import os import ...
1
vote
2answers
93 views

How can I commit all pending queries until an exception occurs in a python connection object

I am using psycopg2 in python, but my question is DBMS agnostic (as long as the DBMS supports transactions): I am writing a python program that inserts records into a database table. The number of ...
1
vote
1answer
216 views

Passing table name as a parameter in psycopg2

I have the following code, using pscyopg2: sql = 'select %s from %s where utctime > %s and utctime < %s order by utctime asc;' data = (dataItems, voyage, dateRangeLower, dateRangeUpper) rows = ...
2
votes
1answer
353 views

dynamically change database (postgresql) in python using psycopg2

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 ...
1
vote
1answer
189 views

psycopg2 not actually inserting data

I need to insert JSON data from tornado to postgres, so here's test like this: from psycopg2 import connect conn = connect("user='pguser' host='localhost' dbname='pgdb' password='pgpass'") cursor = ...
1
vote
1answer
224 views

how to unpickle binary data stored in postgresql by psycopg2 module in python?

I am using cPickle and psycopg2 to store some vectors into database. This is my code to store binary data binary_vec = cPickle.dumps(vec, -1) db.cur.execute(''' INSERT INTO ...
0
votes
1answer
1k views

Libssl and libcrypto causing dyld: Library not loaded: /usr/lib/libpq.5.dylib

I recently uninstalled postgresql and installed pyscopg2 via pip. I know there's some trickery involved with libcrypto and libssl Currently i have them symlinked to: $ ls -lah libssl.* -rwxr-xr-x ...
1
vote
2answers
91 views

Is there a shorter syntax to insert values into a postgres table using psycopg2?

I am trying to insert many columns into a table row using psycopg2 with Python 2.7. Is there a way for me to shorten the INSERT syntax? I currently have to type out the placeholder (%s) over and over ...
1
vote
1answer
407 views

Postgresql server remote connection

I am trying to set up a postgresql 9.1 server on ubuntu, for remote access of data. I have postgres properly installed, the server process is running and I am trying to configure it so that I can ...
1
vote
1answer
135 views

Why does SQLAlchemy with psycopg2 use_native_unicode have poor performance?

I'm having a difficult time figuring out why a simple SELECT query is taking such a long time with sqlalchemy using raw SQL (I'm getting 14600 rows/sec, but when running the same query through ...

1 2 3 4 5
15 30 50 per page