Skip to main content

a generic app to provide a way to handle database binary data in django

Project description

A generic app to provide a way to handle database binary data in django.

Introduction

This is a total rip-off of BinaryField class from Django 1.6+ sourcecode with some tweaks to make it work under Django 1.4+.

Installation

pip install django-binaryfield

Usage

Use BinaryField to bind your binary database columns on a django model. Like so:

from binaryfield import BinaryField

class ExampleModel(models.Model):

    short_data = BinaryField(max_length=10, default=b'\x08')
    data = BinaryField()

Configuration

syncdb

Django-binaryfield works out-of-the-box with existing binary database columns that are correctly mapped in your models. If you want BinaryField to work with syncdb management command there’s one setting called BINARYFIELD_HACK_ENGINES that can be used to hack Django database backend. Use it like this:

BINARYFIELD_HACK_ENGINES = (
    'django.db.backends.sqlite3',
)

It’s a list of django backends (as an “importable” strings) to mangle in order to syncdb could work properly. Did I mention that it is a hack?

Oracle issues

There are some issues with Oracle when handling parameteres in a query in Django < 1.6. You can see this link (https://github.com/django/django/commit/8aefd30379eba9aa7e5afcc69cc352adf0d23489) to see what changed in django.db.backends.oracle.base.OracleParam class regarding this feature.

There are two settings to control a fix to this issue:

  • BINARYFIELD_HACK_ORACLE_PARAM - determines whether or not apply the fix - Default: False

  • BINARYFIELD_HACK_ORACLE_PARAM_BACKENDS - an iterable of backend engines as an “importable” strings to apply the fix. - Default: [ settings.DATABASES['default']['ENGINE'] ]

TODO

  • Some more tests maybe?

  • An example view to show how to serve a file from database

  • try to setup travis-ci testing

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-binaryfield-0.3.1.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_binaryfield-0.3.1-py2.py3-none-any.whl (7.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file django-binaryfield-0.3.1.tar.gz.

File metadata

File hashes

Hashes for django-binaryfield-0.3.1.tar.gz
Algorithm Hash digest
SHA256 a7733bdd6dd8f624b77b92175957ba3c735ad49fbd14369932f24f7214efda6b
MD5 c2a252c6b2ce25b2ee9dc11a2fbc9ff0
BLAKE2b-256 57b7d1f894a68ae53d4e661ea46a083ef8848d3fc62e5a0b5b92b2d5df1e4e79

See more details on using hashes here.

File details

Details for the file django_binaryfield-0.3.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_binaryfield-0.3.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ff0a6c2e58fdc4a18aa52d6e3970f9c674a0187bc52b8d86e7a134b6d03bbbcd
MD5 732f15d1886ea1264a1c4aac07734f68
BLAKE2b-256 3f6676dfd5110fee9e32352000dfd3177e0a5f001e2318036c3dc486871e14b9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page