samedi 28 mars 2015

Establish an ODBC connection between PyQt4 and Oracle11g

I am new to PyQt4 and I apologize in advance if the answer to my question might seem obvious.


Here is the code I am using :



import sys
from PyQt4.QtGui import *
from PyQt4.QtSql import QSqlDatabase

app = QApplication(sys.argv)
w = QTextBrowser()

db = QSqlDatabase.addDatabase("QODBC")
db.setDatabaseName("someBD")
db.setHostName("localhost")
db.setUserName("")
db.setPassword("")

ok = db.open()
print str(db.lastError())

if ok:
w.insertHtml('Connected to MySQL<br />')
else:
w.insertHtml('ERROR connecting to MySQL<br />')

w.show()
sys.exit(app.exec_())


There are no errors loading the driver but the open() fails and I cannot find what is wrong. I am sure of the information I provided (When in doubt I test the connection credentials using Sql Developer)


Aucun commentaire:

Enregistrer un commentaire