« JSP Include | Main | Read a file from a Jython servlet »

April 09, 2012

Getting Jython Django to talk to Postgres

Add the PostgreSQL jar into your CLASSPATH:

export CLASSPATH=$CLASSPATH:/opt/apache-tomcat-7.0.26/webapps/slides/WEB-INF/lib/postgresql-8.4-702.jdbc3.jar

Edit the settings.py file of your application:

#DATABASES = {
#    'default': {
#        'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.                                   
#        'NAME': '',                      # Or path to database file if using sqlite3.   
#        'USER': '',                      # Not used with sqlite3.   
#        'PASSWORD': '',                  # Not used with sqlite3.      
#        'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
#        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
#    }
#}

DATABASE_ENGINE = 'doj.backends.zxjdbc.postgresql'
DATABASE_NAME = 'yourdb'
DATABASE_USER = 'youruser'
DATABASE_PASSWORD = 'yourpasswd'

 

Posted by pj at April 9, 2012 05:10 PM

Comments