Re: [PyQt] QSqlTableModel.rowCount bug? (and still need infor for beforeInsert)
On Freitag 03 Dezember 2010, Andreas Pakulat wrote: > It also doesn't mention that its based on > QSqlQueryModel::rowCount(). That one however does explain > what it returns in its API docs. So it seems like your DB is > at fault, as its not able to return the complete size of the > query. You are right. The Qt SQLITE driver returns False for hasFeature(QSqlDriver.QuerySize) -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] QSqlTableModel.rowCount bug? (and still need infor for beforeInsert)
On 03.12.10 17:13:31, KONTRA, Gergely wrote: > On Fri, Dec 3, 2010 at 15:56, Wolfgang Rohdewald wrote: > > > On Freitag 03 Dezember 2010, KONTRA, Gergely wrote: > > > Hi all! > > > > > > I suspect QSqlTableModel.rowCount cannot return numbers above > > > 256. > > > > rowCount is not the number of rows in the table but in the model, > > AFAIK. Use fetchMore() to load more. > > > > Thats not logical. > http://doc.trolltech.com/4.7/qsqltablemodel.html#rowCountdoesn't > mention what is exactly rowCount, and one should expect the number > of rows based on the name... It also doesn't mention that its based on QSqlQueryModel::rowCount(). That one however does explain what it returns in its API docs. So it seems like your DB is at fault, as its not able to return the complete size of the query. Andreas -- You too can wear a nose mitten. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] QSqlTableModel.rowCount bug? (and still need infor for beforeInsert)
On Fri, Dec 3, 2010 at 15:56, Wolfgang Rohdewald wrote: > On Freitag 03 Dezember 2010, KONTRA, Gergely wrote: > > Hi all! > > > > I suspect QSqlTableModel.rowCount cannot return numbers above > > 256. > > rowCount is not the number of rows in the table but in the model, > AFAIK. Use fetchMore() to load more. > Thats not logical. http://doc.trolltech.com/4.7/qsqltablemodel.html#rowCountdoesn't mention what is exactly rowCount, and one should expect the number of rows based on the name... fetchMore will then fetch all rows. I don't want that, just would like to know the number of rows, or just load the last record. > And can somebody tell me why this code is this painfully slooow? you execute 300 transactions. If you use db.transaction() > after db.open() and db.commit() after model.submitAll(), this > is only one transaction and much faster. > Sounds reasonable, thanks. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] QSqlTableModel.rowCount bug? (and still need infor for beforeInsert)
On Freitag 03 Dezember 2010, KONTRA, Gergely wrote: > Hi all! > > I suspect QSqlTableModel.rowCount cannot return numbers above > 256. rowCount is not the number of rows in the table but in the model, AFAIK. Use fetchMore() to load more. > And can somebody tell me why this code is this painfully slooow? you execute 300 transactions. If you use db.transaction() after db.open() and db.commit() after model.submitAll(), this is only one transaction and much faster. -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] QSqlTableModel.rowCount bug? (and still need infor for beforeInsert)
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 ]--+ | | | Mobile:(+36 20)356 9656 | | | +- "Olyan lángész vagyok, hogy poroltóval kellene járnom!" -+ ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt