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

List:       pykde
Subject:    Re: [PyKDE] QSqlCursor problems
From:       Phil Thompson <phil () river-bank ! demon ! co ! uk>
Date:       2001-12-20 11:45:02
[Download RAW message or body]

Nico van der Walt wrote:
> 
> I am using PyQT3 to access a PostgreSQL database. The data that the SQL
> cursor returns is blank for character fields and 0 for integer fields. The
> correct number of rows are returned.
> 
> Here is a small program I wrote and it's output:
> 
> -----------------------------------------------------------------------------------------------
> 
> import sys
> from qt import *
> from qtsql import *
> 
> a = QApplication(sys.argv)
> 
> db = QSqlDatabase.addDatabase('QPSQL7')
> db.setDatabaseName('test')
> db.setHostName('ns2')
> if not db.open():
>    raise SystemExit
> 
> c = QSqlCursor('gl')
> c.select()
> while c.next():
>         print c.toString(c.editBuffer(),'',':',' | ')
>         print c.value('acc_number').toString()
> 
> ---------------------------------------------------------------------------------------------
> 
> Output:
> acc_number : 0 |  name : '' |  type : ''
> 0
> acc_number : 0 |  name : '' |  type : ''
> 0
> acc_number : 0 |  name : '' |  type : ''
> 0
> 

Hmm, I'm struggling with this. It's definately a bug because the
equivalent C++ code works as expected. The QVariant returned by
QSqlCursor.next() has the right type for the column, and (as you say) it
seems to process each row - it's just the value itself is always zero or
null.

I'll continue to poke around - but any other suggestions are welcome.

Phil


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

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