postgresql

How to map the type Interval in Hibernate ?

Hi, under PostGresql, Im using PersistentDuration for the mapping between the sql type interval & duration but it doesnt work. An other user found the same issue & come with his own class: public void nullSafeSet(PreparedStatement statement, Object value, int index) throws HibernateException, SQLException { if (value == n...

How to move spatial data from Oracle to Postgres

Does anyone have a clear document on how to move Orace Spatial data to Postgres (both Community version and Enterprise DB... Thanks ...

Someway to do `where booleanvalue=false` on both Sql Server and PostgreSQL?

Hello, I am attempting to make an application capable of running on both Sql Server and PostgreSQL. I can not seem to find a common expression that is basically select * from table where booleancol=false on SQL Server I must do(which is very confusing because the default value for bit types must be true or false, but you can't assi...

Postgresql querying two different databases that are having same named tables

Greetings, by using the psycopg2 library of python, I can currently connect to a DB and retrieve such like this: conn = psycopg2.connect("dbname='db1' user='postgres' host='xxxxxx' password='mypass'"); qr = conn.cursor() qr.execute("SELECT avg(pavg) FROM mytable WHERE id =5") Now beside the database named "db1", I have to query anothe...

How to call a function, PostgreSQL

I'm trying to use a function with PostgreSQL to save some data. Here is the create script: -- Function: "saveUser"(integer, character varying, character varying, character varying, character varying, character varying) -- DROP FUNCTION "saveUser"(integer, character varying, character varying, character varying, character varying, chara...

Where can i get any Screencasts for PostgreSQL?

Where can i get any Screencasts, Webcasts, Training Video's, Cbt's ect for PostgreSQL? Thank you in advance ...

Good design for persisting a JPA domain object

I have a domain object that stores some metadata and some raw bytes. This is used for storing binary objects such as PDF documents and images. I would like to persist the metadata in a database so it can be easily queried but I want to store the raw bytes in the file system for performance reasons. What is a good design for achieving th...

Complex ordering in Django

So I am pulling a list of links and I am attempting to sort these links by popularity. I am using the Hacker News algorithm: Y Combinator's Hacker News: Popularity = (p - 1) / (t + 2)^1.5 Votes divided by age factor. Where p : votes (points) from users. t : time since submission in hours. p is subtracted by 1 to negate submitter's ...

Timestamp Difference In Hours for PostgreSQL

I found exactly what I need in MySQL's TIMESTAMPDIFF() but I am having a hell of a time trying to find an equivablent with PostgreSQL. I know I can subtract the two timestamps to get an INTERVAL but I am having a hard time wrapping my head about what it means and specifically I just want the difference between the two timestamps in in h...

Implementing a popularity algorithm in Django

I am creating a site similar to reddit and hacker news that has a database of links and votes. I am implementing hacker news' popularity algorithm and things are going pretty swimmingly until it comes to actually gathering up these links and displaying them. The algorithm is simple: Y Combinator's Hacker News: Popularity = (p - 1) / ...

How to handle unexpected MySQL DB engine changes?

I came across this problem two or three times. One of my customer restored the backup but it modified the engine settings unexpectedly. The result, all foreign-key constraints were lost and the application started showing weird results. The second incident happened on our live production server. MySQL stopped supporting InnoDB and displ...

Rails migrations for postgreSQL schemas

I'm working on a multi-tenant rails application using PostgreSQL schemas for different clients. Rails migrations don't work with multiple schemas out of the box, so I made the following rake task to migrate all schemas and it seems to work. My question is if others have implemented better and more elegant solutions. I would also be reall...

PHP OOP dilemma: how to keep a database connection 'within' a class object?

And here i am again! ;) Im developing (well, im still in planning phase) a web-app where i would give to other developer the possibility to write theyr own plugins/modules (in the way of CMS does, drupal, joomla, etc). My problem is that i have to force the developers to use the methods i wrote for interact with databases, for many rea...

PostGreSql query for equality between two tables

I have two tables A & B and i would like to have a query that : return TRUE ONLY if the two tables are the same (i mean every lines in A are present in B & vice versa, no matter the line order) I have use the keyword EXCEPT but it doesnt work in many cases Thanks for your help. ...

how to force a lock to be obtained in SQL Server?

Hello, I am working on making an application run on both Postgres and SQL Server. in PostgreSQL you can do something like lock mytable exclusive; which would keep the entire table from being written to(insert/updated). I need the entire table to be locked while certain things are updated(and RIDs can not be changed or else it'll scre...

Installing PostgreSQL and pyscopg2 on Snow Leopard

I'm still a complete beginner in the field of web development and I'm trying to set up the Django environment. I'm reading "the definitive guide to django" to start my practice. I'm running Snow Leopard (10.6.2) on a macbook 2.1GHz. It came with Python 2.6.1. Since Snow Leopard cam with Python 2.6.1 preinstalled, so I didn't do any ext...

Will unique RIDs ever "overflow" ?

Hello, I am making an application to run on both SQL Server and PostgreSQL, so I am asking this question about both of them. What happens whenever you create a unique primary key(using a sequence or auto-increment type thing) and you hit over 4 billion records(32 bits)? I'm not saying that our table will have 4 billion records but rath...

How to specify psycopg2 parameter for an array for timestamps (datetimes)

I'd like to run a PostgreSQL query in Python using psycopg2, which filters by a column of type timestamp without timezone. I have a long list of allowed values for the timestamp (rather than a range) and psycopg2 convenient handles arrays, so I thought that this should work: SELECT somestuff FROM mytable WHERE thetimestamp = ANY (%(time...

Looking for free GUI tool to work with PostgreSQL

Currently, I am using standalone GUI tool DbSchema to design my database schema. I like it because it can Generate SQL code. Have graphing view on my entire database schema. However, I realize the SQL code generate by DbSchema is not being recognized by PostgreSQL. CREATE TABLE lot ( lot_id serial AUTO_INCREMENT NOT NULL,...

what's "\." in postgresql dump file?

Hey I have a Postgresql dump file which i'm trying to restore. I get this error regarding an invalid data i guess. ERROR: invalid input syntax for integer: "." and when i checked the file, there are data like this: 469215 2009-10-10 18:16:47.041377 0 1 471217 2009-10-10 18:25:12.536352 0 1 473224 2009-10-17 09:46:43.041...