473,385 Members | 1,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Oracle Access via cx_Oracle

>Shouldn't this be '/u01/app/oracle/product/9.2.0' ? Based on the following
values, that's what I'd expect.
I changed the ORCALE_HOME environment variable to the above suggested value
and got a new error!! That's progress, right? I'm now told:
cx_Oracle.DatabaseError: ORA-12154: TNS:could not resolve service name
/usr/bin/sh: cx_Oracle.DatabaseError:: not found
Is this any help?
Thanks!
Greg Lindstrom (501) 975-4859
NovaSys Health gr************@novasyshealth.com

"We are the music makers, and we are the dreamers of dreams" W.W.

Jul 18 '05 #1
1 8461
"Greg Lindstrom" <gr************@novasyshealth.com> writes:
Shouldn't this be '/u01/app/oracle/product/9.2.0' ? Based on the following values, that's what I'd expect.
I changed the ORCALE_HOME environment variable to the above suggested value
and got a new error!! That's progress, right? I'm now told:
cx_Oracle.DatabaseError: ORA-12154: TNS:could not resolve service name
/usr/bin/sh: cx_Oracle.DatabaseError:: not found
Is this any help?


It is, insofar as this means that Oracle is doing the right thing, but
can't find the database. So let's check how we are telling Oracle
where the database is...

First, when you connect using SQL*Plus, you connect something like
this:

sqlplus user/password@database

Here, "database" is what Oracle refers to as a "connect string",
which translates to IP/port/SID using the Oracle TNSNAMES.ORA file.
myIP = "ww.xx.yy.zzz"
myPort = nnnn
myDsn = cx_Oracle.makedsn(myIP, myPort, 'test1')
This, on the other hand, constructs a connection descriptor (what a
connect string translates to) by hand. Something like

(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = ww.xx.yy.xxx)(PORT = nnnn))
)
(CONNECT_DATA = (SID = test1))
)
oracle = cx_Oracle.connect(myUid, myPwd, myDsn)
Instead of this, could you try

oracle = cx_Oracle.connect(myUid, myPwd, 'database')

where 'database' here is the bit of the SQL*Plus command abover after
the '@' sign? That should make cx_Oracle connect using *exactly* the
same connection descriptor as SQL*Plus uses. If that works, we can
look at why your makedsn call isn't constructing the same descriptor.
(Or, more likely, you can just use the literal connect string that
works, and not bother about gory Oracle details :-))

[elsewhere] Yes, I can hit the Oracle database on the remote (posix) machine with
SQL*Plus running on my Windows box. Does that help me out? Please excuse my
ignorance...I've been using MS-SQL Server for the past 4 or 5 years.


Hang on. Is your Python script running on the Windows box? If so, the
os.putenv stuff is both irrelevant and wrong. On Windows, you don't
need any environment variables. Just skip all the putenv stuff.

Hope this helps,
Paul.

PS If you don't follow any of the above, could you just paste into
your reply the *exact* SQL*Plus command that you use which works for
you. I can then give you a more specific example to try.
--
The most likely way for the world to be destroyed, most experts agree,
is by accident. That's where we come in; we're computer professionals.
We cause accidents. -- Nathaniel Borenstein
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: duikboot | last post by:
Hi all, I'm trying to export a view tables from a Oracle database to a Mysql database. I create insert statements (they look alright), but it all goes wrong when I try to execute them in Mysql,...
1
by: Benson, John | last post by:
Hi, I'm a non-Oracle guy just starting to use Python to explore Oracle. I enclose the Python command prompt log for the usage example further down with only the user, password and host names...
1
by: Greg Lindstrom | last post by:
Hello - I am trying to connect to an Oracle database on an HP-9000 via Python 2.3 and cx_Oracle. I have set the following in my python routine: os.putenv('ORACLE_HOME', '/u01/app/oracle')...
4
by: hot.favorite | last post by:
Hi, I'm fairly new to Python so please pardon any dumbness on my part. I plan to write an app in Python that will run on Linux and would need to connect to Oracle and MySQL. I could use...
17
by: dananrg | last post by:
I'm a little confused about what's out there for database modules at: http://python.org/topics/database/modules.html What I'd like to do is use Python to access an Oracle 9.X database for...
5
by: dananrg | last post by:
I was messing around with the native ODBC module (I am using Python in a Win32 environment), e.g: import dbi, odbc ....and it seems to meet my needs. I'd rather use a module that comes...
0
by: cirudinezidane | last post by:
Hi!! I'd like to install Oracle 10 g express edition over Ubuntu to use with Python 2.4. I have installed Ubuntu, Python 2.4 and Oracle database. I think that I have installed correctly...
0
by: kishorys | last post by:
I have python version 2.5.1 and cx_Oracle version 4.3.1. Oracle is also in running state. I am getting an error while trying to connect to Oracle DB which is installed in my system from python. ...
0
by: harshakusam | last post by:
Hi All, In my python script i use to run some oracle queries for this i require a library to connect to oracle which is cx_Oracle. When we were using 9i(oracle).. my script was running fine.....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.