NuoDB backend for the Django web framework
Python Other
Latest commit 6108a16 Sep 8, 2015 @VDuda VDuda Updating Travis Build recipients
* Removed creyes@nuodb.com
* Removed lbayas@nuodb.com
* Removed rbuck@nuodb.com
* Removed tgates@nuodb.com
* Added drivers@nuodb.com
Permalink
Failed to load latest commit information.
django_pynuodb
test
.travis.yml
LICENSE
MANIFEST.in
Makefile
README.md
__init__.py
django_tests.sh
requirements.txt
setup.cfg
setup.py

README.md

NuoDB - Django

Build Status

This is the community driven Django adapter for NuoDB, with limited support and testing from NuoDB. It leverages the NuoDB Python Driver.

Requirements

The Django version we currently support is Django 1.5.

If you haven't already, Download and Install NuoDB

In the settings.py file in your project, set the USE_TZ flag to False. This is done because the timezone is detected when the connection is created.

Set the ENGINE field in the DATABASES/default dictionary in settings.py to the django_pynuodb folder (if you installed using pip this is just django_pynuodb)

You can optionally set the schema by adding a SCHEMA field in the DATABASES/default dictionary in settings.py, if the schema is not specified it will default to USER

Setup

git clone and install it

git clone https://github.com/nuodb/nuodb-django.git
cd nuodb-django
python setup.py install

or install with pip

sudo pip install django_pynuodb

Migrating from an existing Django app

To migrate data from an exiting Django app using a different database, the process is similar to migrating from another database to NuoDB using the Migration Tool. The difference here is that we will be skpping the schema command. Django requires a specific file structure to function correctly, so in order to ensure that our Django app has the same structure in NuoDB as it does with a different database we will use Django's syncdb command to set up our schema.

To illustrate the steps involved we will use an app deployed with postgresql as an example...

Steps:

  1. Using the NuoDB Migrator, dump the data from your postgresql Django app into a csv file.
$NUODB_HOME/bin/nuodb-migrator dump --source.driver=org.postgresql.Driver --source.url=jdbc:postgresql://localhost/test --source.username=postgres --output.type=csv --output.path=/tmp/dump.cat
  1. From your Django app configured to use NuoDB (for an example of this look in the Sample section below.) perform a syncdb.
python manage.py syncdb
  1. We only performed this syncdb so that we could get the correct table structure for our database. The next step is to empty out the data that Django creates for us so that we have a clean database to import our data from postgresql. We do this using the TRUNCATE TABLE command in nuosql.
nuosql test --user dba --password goalie
SQL> show tables

	Tables in schema USER

		AUTH_GROUP
		AUTH_GROUP_PERMISSIONS
		AUTH_PERMISSION
		AUTH_USER
		AUTH_USER_GROUPS
		AUTH_USER_USER_PERMISSIONS
		DJANGO_CONTENT_TYPE
		DJANGO_SESSION
		DJANGO_SITE
SQL> truncate table user.auth_group;
SQL> truncate table user.auth_group_permissions;
SQL> truncate table user.auth_permission;
SQL> truncate table user.auth_user;
SQL> truncate table user.auth_user_groups;
SQL> truncate table user.auth_user_user_permissions;
SQL> truncate table user.django_content_type;
SQL> truncate table user.django_session;
SQL> truncate table user.django_site;
  1. For our last step we need to import the data from our postgresql database into our new NuoDB database. For this we are going to use the NuoDB Migrator tool's load command.
$NUODB_HOME/bin/nuodb-migrator load --target.url=jdbc:com.nuodb://localhost/test?schema=USER --target.username=dba --target.password=goalie --input.path=/tmp/dump.cat

Sample

Here is a sample database dictionary

DATABASES = {
    'default': {
        'ENGINE': 'django_pynuodb',
        'NAME': 'test',
        'DOMAIN_USER': 'domain',                        # domain credentials
        'DOMAIN_PASSWORD': 'bird',
        'DBA_USER': 'dba',	 			# database credentials
        'DBA_PASSWORD': 'goalie',
        'SCHEMA': '',  					# optional
        'HOST': 'localhost',
        'PORT': '48004',
    }
}

Set the USE_TZ flag to False

USE_TZ = False

Note

  • If you want to add a site to your Django project then you must first delete the example.com site. This is automatically generated by Django with a manually set primary key of 1 and interferes with NuoDB automatically generating further primary keys.

License

NuoDB License