postgresql

DataMapper: using auto_migrate! with many-to-many dependencies?

Hi, I'm trying to migrate my app from MySql to Postgresql, using Rails3-pre and the latest DataMapper. I have several models which are related through many-to-many relationships using :through => Resource, which means that DataMapper creates a join table with foreign keys for both models. I can't auto_migrate! these changes, because I...

Self-join in PostgreSQL view

Hello! I'm trying to create views that would accumulate all the needed data from joined sources: CREATE OR REPLACE VIEW dir AS SELECT dir_data.id, dir_data.parent_id, dir_data.name, (owner.*)::owner, -- owner_id FROM dir_data LEFT JOIN owner ON owner.id = dir_data.owner_id For example, this allows to select ow...

How to store a long data like RFID tag data in a postgres database?

How to store a long data like RFID tag data in a postgres database? The RFID reader gives the BCD data converted into hexadecimal data of 24 bytes. Example:cd00320000a4002a00001042 is the converted data given by the reader. ...

How to write this snippet in Python?

I am learning Python (I have a C/C++ background). I need to write something practical in Python though, whilst learning. I have the following pseudocode (my first attempt at writing a Python script, since reading about Python yesterday). Hopefully, the snippet details the logic of what I want to do. BTW I am using python 2.6 on Ubuntu K...

Postgresql Schema Path permanently

I need to set schema path in Postgres so that I don't every time specify schema dot table e.g. schema2.table. Set schema path (SET SCHEMA PATH a,b,c) only seems to work for one query session on mac, after I close query window (on pg-admin) the path variable sets itself back to default. How can I make it perm ? Would greatly appreciate a...

Nhibernate - How to get rid of unwanted text cast

Hello, I am using Nhibernate 2 and PostgreSql The above code generate a query with a cast on expression res = _session.CreateCriteria(typeof(C)) .Add(Restrictions.Eq("Exp", Exp)) .AddOrder(new Order("Fr", false)) .SetMaxResults(MW) .List<C>(); Exp is a c...

Migrations for PostgreSQL

Red-Gate has very interesting in beta software (Sql Source Control) that is installing inside SSMS and can save schema iterations through commit button. I need the same feature for postgresql, the only way i found similar to this - is log_statement = ddl, but log need be transformed and saved properly to file and than commited. What is y...

PostgreSQL naming conventions

Hi, is anywhere a detailed manual about PostgreSQL naming conventions? (table names vs. camel case, sequences-primary key-constraits etc.) thanx! ...

psycopg2 on cygwin: no such process

I am trying to install postgrepsql to cygwin on a windows 7 machine and want it to work with django. After built and installed postgrepsql in cygwin, I built and installed psycopg2 in cygwin as well and got no error, but when use it in python with cygwin, I got the "no such process" error: import psycopg2 Tracebac...

Web based database administration and browsing for PostgreSQL

Do you know any free or affodrable web based database administration and browsing tool for PostgreSQL? Something like phpMyAdmin for MySQL and better than phpPgAdmin. For MySQL I found Chive that looks promissing. I'm looking for something similiar for PostgreSQL. ...

No getdate() function in Enterprise PostgreSQL

Hi guys, do you have any idea on how to have getdate() function in enterprise postgresql? I upgraded to EDB-PSQL, and now when I tried to restore old data from the free PSQL, it returns error on some tables since there is no getdate(). I believe this should automatically be created upon creating new database? But it didn't. :( Only now()...

Optimal size for Database partitions

Hi all, I am creating a very simple, very large Postgresql database. The database will have around 10 billion rows, which means I am looking at partitioning it into several tables. However, I can't find any information on how many partitions we should break it into. I don't know what type of queries to expect as of yet, so it won't be ...

How to convert a table column to another data type

I have a column with the type of Varchar in my Postgres database which I meant to be integers... and now I want to change them, unfortunately this doesn't seem to work using my rails migration. change_column :table1, :columnB, :integer Which seems to output this SQL: ALTER TABLE table1 ALTER COLUMN columnB TYPE integer So I tried d...

PostgreSQL storing paths for reference in scripts

I'm trying to find the appropriate place to store a system path in PostgreSQL. What I'm trying to do is load values into a table using the COPY command. However, since I will be referring to the same file path regularly I want to store that path in one place. I've tried creating a function to return the appropriate path, but I get a syn...

What db fits me?

Dear Everyone I am currently using mysql. I am finding that my schema is getting incredibly complicated. I seek to find a new db that will suit my needs: Let's assume I am building a news aggregrator (which collects news from multiple website). I then run algorithms to determine if two news from different sites are actually referring to...

postgres - group by on multiple columns - master/detail type table

I have a table order(orderid, ordernumber, clientid, orderdesc etc.,) and a corresponding status for that order on an order_status table ( statusid, orderid, statusdesc, statusNote, statustimestamp) say I have a record in order as below orderid orderumber clientid orderdesc 1111 00980065 ABC blah..blah.....

Converting an int to an IP address

Is there an easy way to convert an int to an IP address in PostgreSQL? I was able to go from IP to int using this code: SELECT inet '1.2.3.4'-'0.0.0.0' This doesn't work: SELECT 16909060::inet I didn't see anything in the documentation. Does anyone know how to do this? ...

How large is a "buffer" in PostgreSQL

I am using pg_buffercache module for finding hogs eating up my RAM cache. For example when I run this query: SELECT c.relname, count(*) AS buffers FROM pg_buffercache b INNER JOIN pg_class c ON b.relfilenode = c.relfilenode AND b.reldatabase IN (0, (SELECT oid FROM pg_database WHERE datname = current_database())) GROUP BY c.r...

how to update xpath_table

Is there a way to update xpath_table in postgres or java ...

Django unit testing: South-migrated DB works in MySQL, throws duplicate PK error in PostGreSQL. Am I missing something or is this a bug?

Hi folks, (Worth starting off with a disclaimer: I'm very new to PostGreSQL) I have a django site which involves a standard app/tests.py testing file. If I migrate the DB to MySQL (through South),, the tests all pass. However in PostGresQL, I'm getting the following error: IntegrityError: duplicate key value violates unique constrain...