[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyQt] ODBC QSqlQuery
From:       Linos <info () linos ! es>
Date:       2007-09-19 10:16:37
Message-ID: 46F0F705.4030504 () linos ! es
[Download RAW message or body]

Hello, i have a problem with QSqlQuery accessing a dsn in linux, i have no problem \
with exactly the same code in windows and i check i have correctly opened the \
datasource, here i paste the relevant code snippets.


-----------------------------------------------------------------------------------------------------------------------------
 import os,  sys, time, re
from PyQt4.QtCore import *
from PyQt4.QtSql import *
from PyQt4.QtGui import *

def conectarMaxdb():
    '''conexion via ODBC con QT a MAXDB'''
    maxdb = QSqlDatabase.addDatabase("QODBC", 'maxdb')
    #maxdb.setDatabaseName("DRIVER={MaxDB \
(Unicode)};HOSTNAME=192.168.1.20;DATABASE=MAXDB2") --> windows code dsn less  \
maxdb.setDatabaseName("DRIVER={MAXDB};ServerNode=192.168.1.20;ServerDB=MAXDB2")  --> \
linux code dsn less  #maxdb.setDatabaseName("DATABASE") --> linux code with dsn
    maxdb.setUserName("FAKE")
    maxdb.setPassword("FAKE")
    aperturamaxdb = maxdb.open()
    if not aperturamaxdb:
        QMessageBox.warning(None,  "Error conexion con la DB",  QString("Database \
Error: %1").arg(maxdb.lastError().text()))  sys.exit(1)
    return maxdb


if __name__ == "__main__":
    app = QApplication(sys.argv)
    dbmaxdb = conectarMaxdb()
    print dbmaxdb.isOpen() -----> print True
    print dbmaxdb.isValid() ----> print True
    query1maxdb =QSqlQuery(dbmaxdb)
    query1maxdb.exec_(QString("SELECT * FROM DATOS_ANTIGUOS.CLIENTES_ANTIGUO WHERE \
CLI='011113'"))  query1maxdb.next()
    print query1maxdb.isValid() ---> print False in linux, True in windows

-----------------------------------------------------------------------------------------------------------------------------



When i use unixODBC commandline  tool isql with "isql DATABASE FAKE FAKE" i can do \
SQL commands in the datasource, i have tested in gentoo (gentoo ebuilds) and debian \
(hand-compiled) with exactly the same results, the same code works well in windows (i \
only have to uncomment, comment the setDatabaseName method because changes in param \
names), anyone knows what can be the problem?


Best Regards,
Miguel Angel.
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic