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

Wolfgang Rohdewald wolfgang at rohdewald.de
Wed Mar 24 16:49:42 GMT 2010


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


More information about the PyQt mailing list