[PyQt] QSqlTableModel.rowCount bug? (and still need infor for beforeInsert)

KONTRA, Gergely pihentagy at gmail.com
Fri Dec 3 14:46:03 GMT 2010


Hi all!

I suspect QSqlTableModel.rowCount cannot return numbers above 256.

For this finding could somebody please write me a mini-example of the
QSqlTableModel.beforeInsert?

Look, this outputs 256 for me (python 3.1.2, pyqt 4.8.1, XP SP3)

And can somebody tell me why this code is this painfully slooow?

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

app = QApplication(sys.argv)
db = QSqlDatabase.addDatabase("QSQLITE")
db.setDatabaseName('test.db')
db.open()

query = QSqlQuery('CREATE TABLE "preferences" ("id"  INTEGER PRIMARY
KEY  AUTOINCREMENT  NOT NULL, "value" varchar)')

model = QSqlTableModel(db=db)
model.setTable('preferences')
model.select()

for i in range(300):
   record = model.record()
   record.setValue('value', str(i))
   res = model.insertRecord(-1, record)
model.submitAll()
print(model.rowCount())

del model, db

thanks
Gergo

+-[ Gergely Kontra <pihentagy at gmail.com> ]------------------+
|                                                           |
| Mobile:(+36 20)356 9656                                   |
|                                                           |
+- "Olyan lángész vagyok, hogy poroltóval kellene járnom!" -+
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20101203/b4c91295/attachment-0001.html>


More information about the PyQt mailing list