postgresql

acts_as_list postgres error on heroku.

We are using has_many_polymorphs along with acts_as_list. Everything works fine locally, but on heroku, we get an error everytime a couple of acts_as_list methods are called. Namely those that update a number of records with new positions because of an addition or a deletion of an item in the list. Example of acts_as_list method: def ...

How to break connections TCP/IP by keepalive postgreSQL without changing anything in the register?

Hy, I have a system working with the client-server structure and PostgreSQL 8.4. My problem is that if a client is editing a record and lose his connection to the server,the TCPIP connection is still considered! So, the record stay allocated for the client in my database. I need the records to be free for edit in a few minutes. There...

indexes needed for table inheritance in postgres?

this is a fairly simple question, but it's one i can't find a firm answer on. i have a parent table in postgres, and then several child tables which have been defined. a trigger has been established, and the children tables only have data inserted if a field, say field x, meets a certain criteria. when i query the parent table with ...

Ruby on Rails: is it okay to use old school database access without migrations?

I'm switching to RoR from ASP.NET MVC. Yeah, migrations are cool, but I do not need to use different databases in my web applications. Postgresql will do just fine. So is it okay if I use PGAdmin to create and administer my databases and schema and avoid all these fancy migrate, rake etc? Update Thanks everyone! Now I better understa...

SQL Populate table with random data

Hello. I have a table with two fields: id(uuid) that is primaryKey and description (var255) I want to insert random data with sql sentance. I would like that description would be something random. Can some1 please help me with this? PS: im using postgresql. ...

Is there a similar function in postgresql for mysql's SQL_CALC_FOUND_ROWS?

hi, everybody using mysql knows: SELECT SQL_CALC_FOUND_ROWS ..... FROM table WHERE ... LIMIT 5, 10; and right after run this : SELECT FOUND_ROWS(); how do i do this in postrgesql? so far, i found only ways where i have to send the query twice... ...

Is there any way to break lost or idle connections TCP/IP in the PostgreSQL 8.4 in a Windows Server 2008?

I've asked: http://stackoverflow.com/questions/3366619/how-to-break-connections-tcp-ip-by-keepalive-postgresql-without-changing-anything And now, I want to confirm: My system (C#.NET, NHibernate and Active Record) is running with a database PostgreSQL 8.4 and a Windows Server. I need a way to break idle or lost TCP/IP connections and u...

Case insensitive search in database with an index?

I'm using Postgres. I have a table of Artices in my database, with a column url for url slugs. These are so that I can display the articles in that table on a website as not "example.com/23323" but instead as "example.com/Funny_Thing_Happened_to_Me". This was straightforward enough to implement, and then as the number of articles grew, ...

Find duplicates in database and rename one

I've got a table in Postgres that is chock full of articles. The articles have a url slug associated with them, which are used to display them as example.com/pretty_name as opposed to example.com\2343. Unfortunately, when I started out, I enforced a unique constraint on urls, but neglected to do so on a case insensitive basis, and I'd l...

Alter Table Set unique problem on postgres

I am using Postgres as DBMS and Django. My model that defines the table is: class TtnetModem(models.Model): ttnetModemSerino=models.CharField(_(u"Seri No"), max_length=20, default='', null=True, blank=True) I change field definition... ttnetModemSerino=models.CharField(_(u"Seri No"), max_length=20, unique= True) on postgres, i ex...

Putting database logic in the application instead of trigger, stored procedures, constraints etc.

I'm using Rails and it does not provide support for database specific actions like triggers, stored procedures and various constraints (not all of them). I wonder if I should put the database logic in the application itself instead. Because then you can make more complex logic than the database provides and it is also database independ...

GeoDjango setup: ERROR: could not access file "$libdir/postgis-1.5": No such file or directory

Update: thought I'd solved it, but I hadn't... please see below. I'm installing GeoDjango on Mac OSX. I've followed the Mac install instructions, which all went smoothly, and am now creating a spatial database template for PostGIS. However, when I try to load the PostGIS SQL routines, I get ERROR: could not access file "$libdir/post...

Django, accessing PostgreSQL sequence

In a Django application I need to create an order number which looks like: yyyymmddnnnn in which yyyy=year, mm=month, dd=day and nnnn is a number between 1 and 9999. I thought I could use a PostgreSQL sequence since the generated numbers are atomic, so I can be sure when the process gets a number that number is unique. So I created a P...

Possible to write MySQL stored procedures in ruby?

I have heard that one in PostgreSQL could write stored procedures in ruby (also python/java/c++). Is this possible in MySQL? Because I dont want to learn their own language for it. Thanks ...

Ruby tutorial for how to write stored procedures for PostgreSQL?

I have heard that one in PostgreSQL can write stored procedures in Ruby. But I haven't been able to find more information about it teaching one how to actually do it. Could someone recommend good sources for that. Thanks ...

Can I just backup postgres's directory while it's running?

I need to back up my database but I don't have enough disk space to dump it. Can I just use duplicity to perform incremental backups on the data directory? Would that corrupt the backup somehow? I don't mind a few of the latest rows missing, but I would like my backup to not be destroyed. Does anyone know what the case is? Thanks! ...

Python error - psycopg2: no appropriate 64-bit architecture?!

I'm running Mac OSX. Until today I had Python 2.6 with psycopg2 running just fine, I was using it with Django and Pylons. I've just reintalled postgres (I don't know if this is connected) and suddenly I can't import psycopg2 into Python without a strange error: >>> import psycopg2 Traceback (most recent call last): File "<stdin>", li...

Foreign key to one of many tables?

The usual way of setting a foreign key constraint is to choose which table the foreign key will point to. I'm having a polymorphic relation between 1 table and a set of table. That means that this table will have a relation with one of those tables in the set. eg. images: person_id, person_type subordinates: id, col1, col2...col9 pro...

Whether to Split Data in to Separate PostgreSQL Table

I am creating an app with a WPF frontend and a PostgreSQL database. The data includes patient addresses and supplier addresses. There is an average of about 3 contacts per mailing address listed. I'm estimating 10,000 - 15,000 contact records per database. When designing the database structure, it occurred to me that rather than storing...

GeoDjango: editing the standard PostGIS template to include OSGB36

I've just installed GeoDjango (yay) and now I'm trying to follow these instructions to set up an existing GeoDjango project, which needs OSGB36: After you've installed and got a PostGIS template, log in to it and update the proj4text column of SRID 27700 to include +datum=OSGB36, and update SRID 29902 to have +datum=ire65. However. I...