Windows 10 and PYODBC

William Abdo w.abdo at ntta.com
Tue Dec 15 11:23:28 EST 2015


Hi Paul Hermeneutic,
The issue was it could not establish a connection , it threw  an error ORA-01019 (1019) .
So after some research it began to look like it was unable to connect via the TNS Names. I was unable to verify this since it was just dying and not logging the issue.
So I started a search for an Oracle based ODBC client since PYODBC is still working with the Microsoft DB’s, I tried cx_Oracle and it worked perfectly after I managed to get the parameters correct on the call,
It utilized all the syntax for the most part of PYODBC calls so only the connection information needed to be altered.
Using parts of a snippet found on the internet that helped me.
Since I still needed PYODBC to talk to SQL Server I found that it worked best if cx_Oracle’s import statement is Place before other ODBC clients. At least it appeared that way to me in my testing.
See Below:
import cx_Oracle #Place before other ODBC Clients
pconnObj  = cx_Oracle.connect('User/Password at TNSname')  #replace with your settings
pcur = pconnObj.cursor()
if pcur.execute('select * from dual'):
    print "Yeah, it works!!!"
else:
    print "Failure"
pcur.close()


I named the cursor the same as I had with PYODBC and no other changes were necessary
.fetchall()
.fetchone()
All worked

Returnd values requested also as PYODBC did:
prows = pcur.execute("SELECT name,TableID,LastAlteredDate  FROM myTable where tableType = '1' order by name").fetchall()
print "#rows=" + str(len(prows)) + '\n'
tscnt = len(prows)

Good Luck!
If you have more questions just ask.

Respectfully,

William Abdo
Software App Engineer II
NTT America, an NTT Communications Company
Office:   +1 561.912.2434
Email:    w.abdo at ntta.com<mailto:w.abdo at ntta.com>
[https://rvip.team-center.net/externals/images/email/ntta.png]<http://www.us.ntt.com/index.html>
[https://rvip.team-center.net/externals/images/email/ntta-twitter.png]<http://www.twitter.com/NTT_America>  [https://rvip.team-center.net/externals/images/email/ntta-linkedin.png] <http://www.linkedin.com/company/ntt-america>   [https://rvip.team-center.net/externals/images/email/ntta-facebook.png] <http://www.facebook.com/nttamerica>   [https://rvip.team-center.net/externals/images/email/ntta-youtube.png] <http://www.youtube.com/user/NTTCommunicationsEN>





From: paul.hermeneutic at gmail.com [mailto:paul.hermeneutic at gmail.com]
Sent: Tuesday, December 15, 2015 10:43 AM
To: William Abdo
Cc: python-list at python.org
Subject: RE: Windows 10 and PYODBC


On Dec 13, 2015 7:20 AM, "William Abdo" <w.abdo at ntta.com<mailto:w.abdo at ntta.com>> wrote:
>
> Problem Resolved.
> I have fixed the Oracle connection issue under Windows 10 with cx_Oracle .
> PYODBC was only failing on the Oracle connection and worked fine on MS SQL under Windows 10.

Please tell us what the fix is. Thanks.

****************************************************************
This email message is intended for the use of the person to whom it has been sent, and may contain information that is confidential or legally protected. If you are not the intended recipient or have received this message in error, you are not authorized to copy, distribute, or otherwise use this message or its attachments. Please notify the sender immediately by return e-mail and permanently delete this message and any attachments. NTT America makes no warranty that this email is error or virus free. Thank you.
****************************************************************



More information about the Python-list mailing list