Giter VIP home page Giter VIP logo

django-oracle-backend's Introduction

django-oracle-backend

It is not easy to override django so that the Oracle driver does not use NVARCHAR2. So here is a very simple package to force usage of VARCHAR2 when creating the database fields.

Installation

pip install git+https://github.com/manelclos/django-oracle-backend.git#egg=django-oracle-backend

Usage

As reported in issue #1 this seems to still be usable.

Add it to your DATABASES configuration, Django will init the classes, see how to use it in the Django documentation: https://docs.djangoproject.com/en/3.1/ref/databases/#subclassing-the-built-in-database-backends

Simple Example Setup

mysite/
    ...
    custom_oracle_engine/
        __init__.py
        base.py

base.py

from django.db.backends.oracle import base

class DatabaseWrapper(base.DatabaseWrapper):
    data_types = base.DatabaseWrapper.data_types.copy()
    data_types.update({
        'CharField': 'VARCHAR2(%(max_length)s)',
        'CommaSeparatedIntegerField': 'VARCHAR2(%(max_length)s)',
        'FileField': 'VARCHAR2(%(max_length)s)',
        'FilePathField': 'VARCHAR2(%(max_length)s)',
        'IPAddressField': 'VARCHAR2(15)',
        'GenericIPAddressField': 'VARCHAR2(39)',
        'SlugField': 'VARCHAR2(%(max_length)s)',
        'TextField': 'CLOB',
        'URLField': 'VARCHAR2(%(max_length)s)',
        'UUIDField': 'VARCHAR2(32)',
    })

settings.py

DATABASES = {
    'default': {
        'ENGINE': 'custom_oracle_engine',
        'NAME': 'XXX',
        'USER': 'XXX',
        'PASSWORD': 'XXX',
        'HOST': 'XXX',
        'PORT': '1521',
    }
}

More documentation can be found here

django-oracle-backend's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

bar350 jeromek13

django-oracle-backend's Issues

Where to init this Package?

Hey i would have a question.

We would like to use this package so my questions:

Where do i init this classes or is there an "new" option to achive this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.