Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I force Django to connect to Oracle using Service Name

Q : How do specify that Django needs to connect to Oracle DB using the service name and not SID ?

Hi,

I am currently telling my Django configuration to connect to Oracle using my SID.

However, I'll need to connect using the service name and not the SID.

APP_DATABASES={
    'default': {
            'ENGINE': 'django.db.backends.oracle',
            'NAME': 'myservice',
            'USER': 'system',
            'PASSWORD': 'admin123',
            'HOST': '192.168.1.45',
            'PORT': '1699',
    }
}

This works fine.

However, When I replace the 'NAME' with the service name as follows

 'default': {
                'ENGINE': 'django.db.backends.oracle',
                'NAME': 'myservice.bose.com',
                'USER': 'system',
                'PASSWORD': 'admin123',
                'HOST': '192.168.1.45',
                'PORT': '1699',
        }

I get a

ORA-12505: TNS:listener does not currently know of SID given in connect descriptor

Clearly Django is telling Oracle to connect using the SID which is not what I want Django to do.

How do specify that Django needs to connect to Oracle DB using the service and not SID ?

Note : I've tested that the service name mentioned above. It works great from Oracle SQL Developer.

Thanks - would really appreciate leads.

like image 607
sbose Avatar asked Oct 08 '13 11:10

sbose


Video Answer


1 Answers

Thanks guys, There's a "documented" solution to this:

        'default': {
                'ENGINE': 'django.db.backends.oracle',
                'NAME': 'host.db.com:1699/oracle_service.db.com',
                'USER': 'user',
                'PASSWORD': 'pass',
        }

Note: The HOST and PORT keys need to be left out of the dictionary - else Django will try connecting with the complete "NAME" as an SID.

like image 200
sbose Avatar answered Sep 20 '22 05:09

sbose