postgresql

Does grails / hibernate store Dates with miliseconds in PostgreSQL?

I'm currently using grails with classes storing java.util.Date fields als DATETIME. However I need the precision / miliseconds to be stored as well which I think is not possible with MySQL. If I switch to PostgreSQL, will it store my Dates with milisecond precision (or is it easy to configure it this way)? ...

Postgres, plpgsql: Is there a way to connect to other DB from inside of a stored procedure?

I have two DB's one is feed by filtered data from another, now i'm using perl script witch executes query on foreign DB, stores a result in a csv file, and loads it to local DB using \COPY sytnatx Is there a way to write plpgsql function witch will connect to foreign DB and load filtered data in local DB ( I know it can be done in ie. p...

Java administration panel

Hi, I'm looking for an administration panel for database written in java that would be similar to Django admin panel. I know that one can generate the forms from entities but I'm searching for a better, customizable solution. Thanks for any help! Best Regards, sass. ...

Combine MongoDB and Postgresql in Rails?

Is it possible to combine AR with MongoMapper/MongoID? If so, are there tutorials/documentations for this? ...

postgresql query to show the groups of a user

Hello, If I create a user in a group, like: create role user_1 login inherit in role group_1; later, with which query could I retrieve to which group(s) a user belongs to ? Thanks ! ...

postgresql trigger when user group is changed ?

Hello, I would like to know if it is possible to have a trigger when a user is added to or drop from a group ? Does this trigger could also works when dierctly create a user in a group (create role ... in group ...) ? (In fact, I want some users of a specified group to have a specific search_path, so I can set/reset the search_path in th...

Postgres Data to XML

Does anyone know any good methods for converting database entries into XML? I.e. if i have a table named "Users" with fields "first_name", "age", "last_name", I'd like to convert the table to: <Users> <first_name>Papa</first_name> <age>50</age> <last_name>John</last_name> </Users> ...

psql: command not found

I installed postgresql via MacPorts. However, going to /opt/local/lib/postgresql84/bin I am unable to execute any of the pg commands. Does anyone know what I am doing wrong? Thank you. ...

How to add python support to already installed postgreSQL?

I have postgreSQL version 8.3 installed on an ubuntu machine. This was installed via apt get. When I was trying to source a database dump that has some plsql functions written, I got the following error - could not access file "$libdir/plpython": No such file or directory When I tried to enable python support for a particular databas...

How to test sql scripts are standard sql in junit tests?

Is there any way to test that SQL scripts contain standard SQL with java/junit tests? Currently we have sql scripts for creating a database etc. in a Postgres db, but when using hsqldb everything fails. That's why I wonder if any java tools exist for testing if sql statements are standard sql. Or would it just be wise to create differe...

Avoid to nest aggregation functions in PostgreSQL 8.3.4

Assuming that my subquery yields a number of rows with the columns (x,y), I would like to calculate the value avg(abs(x-mean)/y). where mean effectively is avg(x). select avg(abs(x-avg(x))/y) as incline from subquery fails because I cannot nest aggregation functions. Nor can I think of a way to calculate the mean in a subquery while kee...

postgresql can't load perl module

Hi, Iam having problem creating postgresql function in plperl CREATE OR REPLACE FUNCTION zm_json (TEXT, TEXT) RETURNS TEXT AS $$ use JSON::XS; # do something return $json_out; $$ LANGUAGE plperl; When i want to create function above iam getting ERROR: creation of Perl function "zm_json" failed: Unable to load JSON/XS.pm into...

How to create postgres date index properly?

Hi. I'm using Django ORM and postgresql. ORM creates a query: SELECT (date_part('month', stat_date)) AS "stat_date", "direct_keywordstat"."banner_id", SUM("direct_keywordstat"."total") AS "total", SUM("direct_keywordstat"."clicks") AS "clicks", SUM("direct_keywordstat"."shows") AS "shows" FROM "direct_keywor...

SQLAlchemy override types.DateTime on raw sql expressions

is it possible to override the default type.DateTime behaviour when using sqlalchemy with raw sql expressions? for example when using myconnection.execute(text("select * from mytable where mydate > :mydate), {'mydate': mypythondatetimeobject)} , i would like to have type.DateTime to automatically strip the TimeZone from the DateTime ...

geodjango syncdb errors. From geodjango tutorial.

I have followed the geodjango installation(windows XP) and tutorial to perfection I am running django 1.2 When I get to syncdb and run I receive the following. raise ImproperlyConfigured(error_msg) django.core.exceptions.ImproperlyConfigured:'django.db.backends.postgis' isn an available database backend. Try using django.db.backend...

Crystal Reports PostgreSQL inet query

I'm trying to create a report that allows a user to select a branch that they want to view traffic for in Crystal Reports 11. The data type in question is of the inet data type in PostgreSQL, I cannot change it. Because of this, it appears as though the "Like" operator will not work correctly. About the Inet Data Type: http://www.post...

Postgresql object ID and tuples

Hi, I sometimes see messages like Process 12990 waits for ExclusiveLock on tuple (889,66) of relation 17720 of database 17607; blocked by process 12992. So of course the 'process' part is quite clear, but I don't know how to correlate between the relation ID and a human readable name. I also don't really know what to make of the tup...

Query to group by maximum depth of PostgreSQL Ltree?

I want to query for all products with the name "Shania Twain", but I want group them only by the tree with the deepest nlevel. Assuming I have a table like the following with the name categories +---------------+---------------+---------------+ |id |name |tree | +---------------+---------------+---------...

What is an efficient way to do pattern match in MySQL?

We have a huge pattern match in a query (about 12 strings to check). Now I have to do this query in MySQL, but it seems that the query from PostgreSQL has not the same syntax. From PostgreSQL: SELECT value FROM ... WHERE ... AND `value` !~* '.*(text|text2|text3|text4|text5).*'; How do I do this in MySQL in a efficient way? ...

Django: pkey is none after saving

Hi, I have a strange behaviour on my Django/PostgreSQL system. After saving a model object the primary key is none although it's an AutoField and the id is correctly saved in the database. The following script passage returns None for the id: a = SomModelClass() a.someattribute = 'xyz' a.save() a.someattribute >>> 'xyz' a.id >>> None...