I would like to change my functions in PyQGIS from SQLite databases to Geopackages. However, the SQL statements don't quite work as I had hoped. My table has the columns: task, completed, date With SQLITE the following function works as intended (see comments) with the Geopackage I get the following error message: AttributeError: 'list' object has no attribute 'fetchedRowCount'.
What am I doing wrong?
working solution shows checkbox in the ListWidget, geopackage Version does not:
def updateList(self, date):
self.tasksListWidget.clear()
md = QgsProviderRegistry.instance().providerMetadata("ogr")
con = md.createConnection( dbfile, {})
# db = lite.connect(dbfile)
# cursor = db.cursor()
row = (date,)
query = 'SELECT task, completed FROM tasks WHERE date ="%s"' %(row)
# results = cursor.execute(query, row).fetchall()
results = con.executeSql(query).fetchedRowCount()
for result in results:
item = QListWidgetItem(str(result[0]))
item.setFlags(item.flags() | Qt.ItemIsUserCheckable)
if result[1] == "YES":
item.setCheckState(Qt.Checked)
elif result[1] == "NO":
item.setCheckState(Qt.Unchecked)
self.tasksListWidget.addItem(item)