2014-01-02-a-better-pygresql-support-for-django.md 3.0 KB


title: A better PyGreSql support for Django author: admin type: post date: 2014-01-02T21:33:40+00:00 url: /a-better-pygresql-support-for-django/ tumblr_gethue_permalink:

  • http://gethue.tumblr.com/post/72002742226/a-better-pygresql-support-for-django tumblr_gethue_id:
  • 72002742226 sf_thumbnail_type:
  • none sf_thumbnail_link_type:
  • link_to_post sf_detail_type:
  • none sf_page_title:
  • 1 sf_page_title_style:
  • standard sf_no_breadcrumbs:
  • 1 sf_page_title_bg:
  • none sf_page_title_text_style:
  • light sf_background_image_size:
  • cover sf_social_sharing:
  • 1 sf_sidebar_config:
  • left-sidebar sf_left_sidebar:
  • Sidebar-2 sf_right_sidebar:
  • Sidebar-1 sf_caption_position:
  • caption-right categories:
  • Development

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:

  1. Download django-pygresql.
  2. Run

    unzip master.zip && cd django-pygresql-master && /build/env/bin/python install setup.py

  3. At the bottom of /desktop/core/src/desktop/settings.py, add the following code:

  4. if DATABASES['default']['ENGINE'] == 'django_pygresql':
      SOUTH_DATABASE_ADAPTERS = {
        'default': 'south.db.postgresql_psycopg2'
      }
    1. 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.

     

    Write to us athue-user mailing list or@gethue!