Python Connection To Database

Trying to step through one of those Oracle By Example exercises that demonstrates Oracle/Python connections.   I can understand that listener does not currently know of service requested in connect descriptor, but can't determine where the connect descriptor is .  Assuming (conn_parms), but can't locate point in the base.py where parms are set up.
Where in the base.py  do i get the connection parameters?

 File "/Library/Python/2.7/site-packages/django/db/backends/base/base.py", line 119, in connect
    self.connection = self.get_new_connection(conn_params)
  File "/Library/Python/2.7/site-packages/django/db/backends/oracle/base.py", line 214, in get_new_connection
    return Database.connect(conn_string, **conn_params)
django.db.utils.DatabaseError: ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
base.py
urls.py
xoxomosAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

slightwv (䄆 Netminder) Commented:
I don't know anything about Python but it looks like this is where everything is set up:  def _connect_string(self)  If the values aren't provided, there are defaults set.

From your previous question, my guess is the settings are in settings.py.
0
xoxomosAuthor Commented:
Me neither :-)  My guess was the same as yours regarding settings.py so i put in my desktop
# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE':   'django.db.backends.oracle',
        'NAME':      'Axum/XE',
        'USER':        'pythonhol',
        'PASSWORD': 'n31l',



Noticing the urls.py in the download is a bit different from the one on the webpage.
from django.conf.urls import include, url
from django.contrib import admin

urlpatterns = [
    # Examples:
    # url(r'^$', 'mysite.views.home', name='home'),
    # url(r'^blog/', include('blog.urls')),

    url(r'^admin/', include(admin.site.urls)),
]
~                                  
    }
}
0
slightwv (䄆 Netminder) Commented:
>> 'NAME':      'Axum/XE',

That doesn't look right to me.  Guessing based on several different programming languages and connections to Oracle, this is likely the alias name in the tnsnames.ora file.

That guess seems to be supported by the docs:
https://docs.djangoproject.com/en/1.8/ref/databases/

onnecting to the database¶

To connect using the service name of your Oracle database, your settings.py file should look something like this:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.oracle',
        'NAME': 'xe',
        'USER': 'a_user',
        'PASSWORD': 'a_password',
        'HOST': '',
        'PORT': '',
    }
}

In this case, you should leave both HOST and PORT empty. However, if you don’t use a tnsnames.ora file or a similar naming method and want to connect using the SID (“xe” in this example), then fill in both HOST and PORT like so:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.oracle',
        'NAME': 'xe',
        'USER': 'a_user',
        'PASSWORD': 'a_password',
        'HOST': 'dbprod01ned.mycompany.com',
        'PORT': '1540',
    }
}

You should either supply both HOST and PORT, or leave both as empty strings. Django will use a different connect descriptor depending on that choice.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

xoxomosAuthor Commented:
Yes thanks.  I saw that a little while back and added port and host but it did not make a difference.  The error coming back is complaining listener does not know of  SID although SID and service name should be the same in this case.
0
xoxomosAuthor Commented:
If i could figure out what it wants in that conn_string and **conn_params id just hard code it into the base.py and try to work backwards from there :-)
0
xoxomosAuthor Commented:
File "/Library/Python/2.7/site-packages/django/db/backends/oracle/base.py", line 214, in get_new_connection
    return Database.connect(conn_string, **conn_params)
0
slightwv (䄆 Netminder) Commented:
>>he error coming back is complaining listener does not know of  SID although SID and service

That error means you made it to the sever but you have the wrong service name or as the error suggests, the service name you provided isn't there.

As I said, "Axum/XE" doesn't look right.

I remember the XE service just being 'XE' as in the documentation.  I've also never seen a service name with a '/' in it.

>>just hard code it

Go with what has been set up for you...  Just provide correct values.
0
xoxomosAuthor Commented:
Service "CLRExtProc" has 1 instance(s).
  Instance "CLRExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "XEXDB" has 1 instance(s).
  Instance "xe", status READY, has 1 handler(s) for this service...
Service "xe" has 1 instance(s).
  Instance "xe", status READY, has 1 handler(s) for this service...
The command completed successfully

This is the XE i'm using for service name.
0
slightwv (䄆 Netminder) Commented:
>>This is the XE i'm using for service name.

XE should be used but you had Axum/XE.  Try with NAME set to just XE.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
xoxomosAuthor Commented:
Thanks
0
xoxomosAuthor Commented:
BIG THANKS !!! ... i think
0
xoxomosAuthor Commented:
Well it's made the connection successfully and did some stuff.  Now i have to figure out how to respond to a ' do you want to configure superuser now'?
Thanks again.
0
slightwv (䄆 Netminder) Commented:
Cannot help with the answer to the superuser question.
0
xoxomosAuthor Commented:
Say 'yes'.  I had used just the 'xe'  in a previous trial, but said no.  Then when i looked for the 'django' tables and they were not there i started putting in Auxm/xe, and of course never even gotten to the point where i had to make a yes/no choice again. :-(
Thanks again.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Python

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.