postgresql

Doctrine SQL query: works on MySQL, on PostgreSQL won't

This is a query automatically generated by Taggable extension for Doctrine ORM. SELECT t.id AS t__id, t.name AS t__name, COUNT(DISTINCT i.id) AS i__0, (COUNT(DISTINCT i.id)) AS i__1 FROM taggable_tag t LEFT JOIN cms__model__image_taggable_tag c ON (t.id = c.tag_id) LEFT JOIN image i ON i.id = c.id WHERE t.id IN (SELECT doctrine_s...

Can't install egenix-mx-base on Django production VPS

I have been following these instructions for setting up a Django production server with postgres, apache, nginx, and memcache. My problem is that I cannot get egenix-mx-base to install and without this I cannot get psycopg2 to work and therefore no database access :(. I am attempting this on a VPS running a clean install of Ubuntu Hard...

Cannot save model due to bad transaction? Django

Trying to save a model in Django admin and I keep getting the error: Transaction managed block ended with pending COMMIT/ROLLBACK I tried restarting both the Django (1.2) and PostgreSQL (8.4) processes but nothing changed. I added "autocommit": True to my database settings but that didn't change anything either. Everything that Google...

News feed APIs for general news

I'm building a database + tool that scours news feeds for a certain term. For example "food poisoning from nuts". I want to scour social media sites, news sites, major news aggregators, etc... for that term. Question 1: What are some of the news aggregator APIs out there? Question 2: How Would you go about coding and receiving only the...

Logging SELECT statements in PostgreSQL 8.4

Hi All I've got a table which contains sensitive data and according to data protection policy we have to keep a record of every read/write of the data including a row identifier and the user who accessed the table. The writing is no issue using triggers but triggers aren't supported for SELECT statements. What's the best method of doin...

How to install gem pg on snow leopard

I need to install gem pg on snow leopard because I am running rake on rails codebase. I am not using postgres. This is the error I am getting. $ sudo gem install pg Password: Sorry, try again. Password: Building native extensions. This could take a while... ERROR: Error installing pg: ERROR: Failed to build gem native extension. ...

Query results taking too long on 200K database, speed up tips?

I have a sql statement where I'm joining about 4 tables, each with 200K rows. The query runs, but keeps freezing. When I do a join on 3 tables instead, it returns the rows (takes about 10secs). Any suggestion why? suggestions to speed up? Thanks! Code SELECT * FROM equipment, tiremap, workreference, tirework WHERE equipment.tiremap = ...

postgreSQL - pg_class question

PostgreSQL stores statistics about tables in the system table called pg_class. The query planner accesses this table for every query. These statistics may only be updated using the analyze command. If the analyze command is not run often, the statistics in this table may not be accurate and the query planner may make poor decisions which...

How to select rows which start with digit in PostgreSQL?

Need to get rows starting with digit e.g. '1test', '32 test'. I tried SELECT * FROM table WHERE name LIKE '[0-9]%' as I used to do in MSSQL but it wasn't successful. ...

Rollback to a specific moment with PostgreSQL

Hi, Is there a way to rollback to a specific starting point. Im looking for something like this. Start specific_point; Now after this, an other application connected with the SAME login will insert & delete datas (webservices with crud operations) for about 2 minutes doing tests. Each webservice call is declared as a transaction with S...

PL/PGSQL function, having trouble accessing a returned result set from psycopg2...

I have this pl/pgsql function: CREATE OR REPLACE FUNCTION get_result(id integer) RETURNS SETOF my_table AS $ DECLARE result_set my_table%ROWTYPE; BEGIN IF id=0 THEN SELECT INTO result_set my_table_id, my_table_value FROM my_table; ELSE SELECT INTO result_set my_table_id, my_table_v...

postgres - ERROR: syntax error at or near "COST"

EDIT Taking COST 100 out made the command go through, however, I'm still unable to run my query because it yields this error: ERROR: function group_concat(character) does not exist HINT: No function matches the given name and argument types. You may need to add explicit type casts. The query I'm running is this: select tpid, group_...

How do I create a postgresql user with fabric

I want to create a database user for my setup fabric script but createuser has interactive password entering and seams not to like fabric. ...

postgres - ERROR: operator does not exist

Again, I have a function that works fine locally, but moving it online yields a big fat error... Taking a cue from a response in which someone had pointed out the number of arguments I was passing wasn't accurate, I double-checked in this situation to be certain that I am passing 5 arguments to the function itself... Query failed: ERRO...

how to declare variable in PostgreSQL

I try to declare a variable in a code like this, but it's doesn't work. Can you tell me what's the problem? ERROR: syntax error at or near "VARCHAR" LINE 2: p_country VARCHAR; DECLARE p_country VARCHAR; p_country : = ''; SELECT p_country; ...

PostgreSQL activerecord weirdness for .maximum

I have an ActiveRecord before_save method throwing an odd error: class MyThing < ActiveRecord::Base before_save :dostuff def dostuff p self.class.maximum(:mycolumn) end end When I was using SQLite this worked perfectly, now—with postgresql—I get the error: PGError: ERROR: current transaction is aborted, commands ignored un...

Connection error with heroku db:push with postgresql

I have suddenly started seeing this strange error when trying to push my database to heroku. > heroku db:push Auto-detected local database: postgres://infinity:infinity@localhost/infinity_development?encoding=utf8 Failed to connect to database: Sequel::DatabaseConnectionError -> TypeError wrong argument type String (expected Array) My...

Statistical analysis on large data set to be published on the web

I have a non-computer related data logger, that collects data from the field. This data is stored as text files, and I manually lump the files together and organize them. The current format is through a csv file per year per logger. Each file is around 4,000,000 lines x 7 loggers x 5 years = a lot of data. some of the data is organized a...

PHP calling PostgreSQL function - type issue?

I have a function in PostgreSQL / plpgsql with the following signature: CREATE OR REPLACE FUNCTION user_login(TEXT, TEXT) RETURNS SETOF _get_session AS $$ ... $$ Where _get_session is a view. The function works fine when calling it from phpPgAdmin, however whan I call it from PHP I get the following error: Warning: pg_query() [functi...

What is causing System.AccessViolationException when I access an ADODB Field's Value?

I am connecting to a PostgreSQL database from a .Net web service (both on a Windows XP machine). On a few occasions recently, on a few different computers, we have received System.AccessViolationException errors. One stack trace I was able to obtain showed that it was occuring when I took an ADODB.recordset and obtained the value of a ...