With the release of django-pygresql, the Hue team has taken a first stab at PyGreSQL support in Django!
The ‘Why’
The open source world has many different kinds of licenses and it can be confusing to know which one makes sense for you. PyGreSQL is a PostgreSQL client with a permissible enough license that it can be packaged and shipped.
The ‘How’
PyGreSQL has some minor differences from the provided postgresql backend. It required a few changes including:
- Massaging Date/Datetime/Time types to work with Django.
- A custom cursor for massaging data.
- Custom autocommit management.
To install this backend:
-
Download django-pygresql.
-
Run
unzip master.zip && cd django-pygresql-master && /build/env/bin/python install setup.py
-
At the bottom of
/desktop/core/src/desktop/settings.py, add the following code:
if DATABASES['default']['ENGINE'] == 'django_pygresql': SOUTH_DATABASE_ADAPTERS = { 'default': 'south.db.postgresql_psycopg2' }
- In the hue.ini, set desktop->database->engine to “django_pygresql”. Then, add the normal postgresql configuration parameters.
Summary
This is an initial implementation of a backend for Django to communicate with PostgreSQL via PyGreSQL. We hope this helps other members of the community.