postgresql

PostgreSQL and JMS (Or other Pub-Sub/Callback Mechanism)

I want to have my PostgreSQL server send out notifications when a piece of data changes, preferably over JMS, but also considering any other Pub-Sub mechanism or Callback. Any ideas if this is possible? Are there any available Java Add-on Packages that replicate this sort of functionality? ...

PostgreSQL - Updating an Enum Type

I've got a field that is using an enumeration type. I wish to update the enum to have an additional field (I don't want to delete anything, just add a new label). What is the simplest way to do this? ...

PostgreSQL and Point in Time Recovery

I was reading through this: http://www.postgresql.org/about/ And I saw this: An enterprise class database, PostgreSQL boasts sophisticated features such as ... point in time recovery I need some light shed on this subject and its features and examples of it in action or share their own performance experiences? ...

postgresql and python

I need to visualize spatial data (20 polygons) from "postgis" database (postgresql), with python. I know how to connect postgresql database with python only, but I don`t how to visualize those polygons. It is project for my university. We need to use for example matplotlib and create application in python which will visualize shapefiles ...

Data visualization in python - after connecting to a database

Can you help me to connect to my postgresql database with python? I need to create graphic interface with python which will visualize shapefile data from my database (i have about 50 polygons in shapefile format in that database). Can you help me with creating such application? I am begginer in python. ...

Postgresql for OLAP

Does anyone have experience of using postgresql for an OLAP setup, using cubes against the database etc. Having come across a number of idiosyncracies when using MySql for OLAP, are there reasons in favour of using postgresql instead (assuming that I want to go the open source route)? ...

To insert to Pg by Psycopg

How can you fix the SQL-statement in Python? The db connection works. However, cur.execute returns none which is false. My code import os, pg, sys, re, psycopg2 try: conn = psycopg2.connect("dbname='tk' host='localhost' port='5432' user='naa' password='123'") except: print "unable to connect to db" cur = conn.cursor() print cur...

SQL: Looking up the same field in one table for multiple values in another table?

(Not sure if the name of this question really makes sense, but what I want to do is pretty straightforward) Given tables that looks something like this: Table Foo --------------------------------- | bar1_id | bar2_id | other_val | --------------------------------- Table Bar -------------------- | bar_id | bar_desc| -------------------...

Converting SQL commands to Python's ORM

How would you convert the following codes to Python's ORM such as by SQLalchemy? #1 Putting data to Pg import os, pg, sys, re, psycopg2 #conn = psycopg2.connect("dbname='tkk' host='localhost' port='5432' user='noa' password='123'") conn = psycopg2.connect("dbname=tk user=naa pass...

Best way to handle concurrency issues

Hi guys, i have a LAPP (linux, apache, postgresql and php) environment, but the question is pretty the same both on Postgres or Mysql. I have an cms app i developed, that handle clients, documents (estimates, invoices, etc..) and other data, structured in 1 postgres DB with many schemas (one for each our customer using the app); let's a...

Postgres math expression calculcated for each row in table

Using PostgreSQL, supposing a table like the following: 12184 | 4 | 83 12183 | 3 | 171 12176 | 6 | 95 How can I compute a math expression for each row in the table? For example, to divide column 2 by column 3, such that the output would be: 12184 | 0.04819277...

postgres - partial column in SELECT/GROUP BY - column must appear in the GROUP BY clause or be used in an aggregate function

Both the following two statements produce an error in Postgres: SELECT substring(start_time,1,8) AS date, count(*) as total from cdrs group by date; SELECT substring(start_time,1,8) AS date, count(*) as total from cdrs group by substring(start_time,1,8); The error is: column "cdrs.start_time" must appear in the GROUP BY clause or ...

rails db neutral pivot table or crosstab

Does anyone know of a way to build a pivot table using activerecord which would be remotely DB neutral? I've tried to avoid using find_by_sql and DB specific queries but for a pivot table or crosstab query I have no idea how to do it in a way which is not specific to say MySQL. IE my mySQL find_by_sql breaks on a postgresql DB. I foun...

plotting data from postgresql in python

Can you help me with plotting data from postgresql database (postgis) in python with matplotlib? There are .shp polygons in that database. I need to create simple graphic interface to show those polygons. (cant use any other software, only python and matplotlib). Thank you! ...

pygame and postgresql

How to draw vector objects from database in python with pygame? ...

Postgresql HAVING clause limitation

Why can't one use an output column in the having clause in postgresql? It doesn't change expressivity of the language anyhow, just forces people to rewrite output column definition in having clause. Is a way to avoid that, apart from putting the whole query as a subquery in SELECT * FROM (...) AS t WHERE condition ? ...

postgresql execParams paramTypes meaning?

I'm trying to perform an insert (C++) using different datatypes using execParams, but it keeps saying that the insert is failing. I believe this is because It's interpreting all my datatypes as text because I've set paramTypes to NULL. The documentation says If parameters are used, they are referred to in the command string as $1...

PostgreSQL: database restore from dump - syntax error

Hi folks, I'm trying to restore a PostgreSQL database by executing the SQL that pg_dump created, on an empty database. I'm getting this error: ERROR: syntax error at or near "\" LINE 5211: \. lines 5210 and 5211 read: COPY auth_group (id, name) FROM stdin; \. It works fine on my Linux server, where I use this command: psql -U ...

PostgreSQL: UPDATE implies move across partitions

(Note: updated with adopted answer below.) For a PostgreSQL 8.1 (or later) partitioned table, how does one define an UPDATE trigger and procedure to "move" a record from one partition to the other, if the UPDATE implies a change to the constrained field that defines the partition segregation? For example, I've a table records partitio...

NHibernate calling PostgresSQL's SELECT DISTINCT ON ()

Hello, Before asking this question I have googled for some time, but could not find any relevant information on this topic. My problem is simple: I have NHibernate criteria and projection and I'm trying to set DISTINCT ON(column) My code for projection is following: criteria.SetProjection( Projections.ProjectionL...