[PyQt] How to retrieve number of fields of a query from QSqlQuery object

2010-03-24 Thread bar tomas
Hi,
QSqlQuery's size method gives the number of rows retrieved with a
query. But is there some way to get the number of fields (columns) of
that query?
Many thanks.
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] How to retrieve number of fields of a query from QSqlQuery object

2010-03-24 Thread Wolfgang Rohdewald
On Mittwoch 24 März 2010, bar tomas wrote:
> Hi,
> QSqlQuery's size method gives the number of rows retrieved
> with a query. But is there some way to get the number of
> fields (columns) of that query?
> Many thanks.

if self.query.isSelect():
  record = self.query.record()
  qFields = [record.field(x) for x in range(record.count())]

-- 
Wolfgang
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt