My Python & co. stuff

Archive for the ‘PostgreSQL’ Category

… just use pg_ctl register:

C:> set PGDATA=c:\postgresql-8.4-data
C:> pg_ctl register -N PostgreSQL
C:> net start PostgreSQL

Advertisements

UPDATE: There is a Google Code project on django+postgresql+INTERVAL available here.

Here you are. Idea taken from zboczuch:

from datetime import timedelta
from django.conf import settings

class IntervalField(models.Field):

    def db_type(self):
        if not settings.DATABASE_ENGINE.startswith('postgresql'):
            raise NotImplementedError
        return "interval"

    def to_python(self, value):
        assert(isinstance(value, timedelta))
        return value

    def _seconds(self, value):
        return value.days * 24 * 60 * 60 + value.seconds + (value.microseconds / 1000000.0)

    def get_db_prep_value(self, value):
        if value is None: return None
        return '%f' % self._seconds(value)