django-firebird
This is a firebird backend implementation for django that enables Firebird (version 1.5 and later) RDBMS support.
Currently it works only with Django 1.1 (trunk revision) This module is based on version of Hajime Nakagami, which I (maxirobaina) have improved to work with django 1.1 and Firebird 1.5 and Firebird 2.x
This is alpha software - use it at your own risk.
Installation
Prerequisites
- KInterbasDB package (http://www.firebirdsql.org/index.php?op=devel&sub=python)
- Get django 1.1 (http://www.djangoproject.com/download/)
Go ahead... Download the zip file, extract it and copy under django/db/backends/ folder on your django installation or... Check out the latest development version anonymously with:
$ svn checkout http://django-firebird.googlecode.com/svn/trunk/ django-firebird-read-only
Differences from other Django backends
- TextField. Since large and very large VARCHARs work better than BLOBs with Firebird in most cases where Django uses TextField, Firebird backend uses VARCHAR columns for TextFields and BLOB columns for LargeTextField. For more info see http://www.volny.cz/iprenosil/interbase/ip_ib_strings.htm#_strings_blob_varchar.
With Firebird backend TextFields have max_length and encoding attributes that are ignored by other backends.
By default, TextFields have max_length of 10921 (with default UNICODE_FSS 3-byte charset), 8191 (with optional 4-byte UTF8 charset) or 32765 (with custom 1-byte encoding) -- maximum allowed. If there are multiple TextFields, their size could be adjusted to fit the 64k row limit and warning will be genererated. It's better to set explicit max_length attribute in this situation.
If you need to store more text you could use LargeTextField or split your text across multiple rows.
- Index Limit. 252 bytes with Firebird < 2.0 and 1/4 of page size in later versions. You may need to add encoding="ascii" and/or adjust max_length of CharFields used as indexes or unique/primary keys to work around these Firebird limitations. Current implementation adjusts these fields automagically and generates warnings during validation process. It's better to adjust these fields manually or switch to Firebird > 2.0 and/or increase the page size.
- Foreign Key Constraints. FK constraint in Firebird are stricter - no forward references allowed, even inside transactions.
Usage
In setting.py
DATABASE_ENGINE = 'firebird'
DATABASE_NAME = 'path_to_database' # Path to database or db alias
DATABASE_USER = 'SYSDBA' # Your db user
DATABASE_PASSWORD = 'masterkey' # db user password
DATABASE_HOST = '127.0.0.1' # Your host machine
DATABASE_PORT = '3050' # If is empty, use default 3050
DATABASE_OPTIONS = {'charset':'ISO8859_1'} #If is not defined, use default UNICODE_FSS