[PyQt] 256 record limit with QOdbc working with MS Access

Scott Price scottmprice at gmail.com
Thu Nov 5 18:41:17 GMT 2009


Hello,

Using Python 2.6, PyQt 4.4.4 on Windows XP sp3.

I can't seem to find this information in the regular documentation, nor 
does Google seem to help.  MS's website is not helpful either 
researching whether this is a limit set from within Access for outside 
'access' (bad pun) using odbc.

I'm executing a QSqlQuery against a MS Access 2003 .mdd database using 
the QOdbc database connection.  The result set is cut short at 256 
records when there are nearly 2000 records that should be returned.  
This is a legacy database I'm working with, so please no Access bashing 
for the moment... I'm very well aware of the shortcomings of Access (I 
was the Access forum leader for a help forum for a time).

I've managed to work up a test case that replicates the behavior using 
an mdb file.  I tried to attach the mdb file, but was rejected by the 
mailing list.  If anyone wants to try with it, let me know and I can 
email it.  There are 503 dummy records in the database table.  All 503 
should be returned, as can be seen by running the very same sql query 
from inside Access.

The main window portion of the .py file is probably unnecessary to 
reproduce the behavior, but I left it in from laziness (didn't want to 
rewrite the whole thing...)

Anyone have any idea why the query only returns 256 records?  Any ideas 
on where I can even start looking for the cause?  Is this an Access 
limitation or a PyQt limitation?



Thanks,
scott

------------------------------------------------------------------------

#!/usr/bin/env python
import sys
import os
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtSql import *


class MainWindow(QDialog):

    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.tabWidge = QTabWidget()
        
        qryTest = QSqlQuery()
        qryTest.exec_("""SELECT tblPerson.FamilyName FROM tblPerson;""")
        
        if qryTest.isActive():
            print qryTest.size()
        
        qryModel = QSqlQueryModel()
        qryModel.setQuery(qryTest)
        print qryModel.rowCount()
        
        self.grid = QGridLayout()
        self.grid.addWidget(self.tabWidge)
        self.setLayout(self.grid)
       
    def closeEvent(self, event):
        
        db.close()
 
if __name__ == "__main__":
   
    app = QApplication(sys.argv)
    
    filename = os.path.join(os.path.dirname(__file__), "test.mdb")
    create = not QFile.exists(filename)
    db = QSqlDatabase.addDatabase("QODBC")
    db.setConnectOptions("SQL_ATTR_TRACE=SQL_OPT_TRACE_OFF")
    db.setDatabaseName("DRIVER={Microsoft Access Driver (*.mdb)};FIL={MS Access};DBQ=%s" % filename)
    if not db.open():
        QMessageBox.warning(None, "Test DB", QString("Database Error: %1").arg(db.lastError().text()))
        db.close()
        sys.exit(1)
    
    
    window = MainWindow()
    window.setGeometry(50, 50, 800, 600)
    window.show()
    
    sys.exit(app.exec_())
	





More information about the PyQt mailing list