<div dir="ltr"><div>Hi Raymond,</div><div><br></div><div>your code looks good.</div><div><br></div><div>Can you provide a test file?</div><div><br></div><div>There are some test in core here: <a href="https://github.com/qgis/QGIS/blob/master/tests/src/python/test_qgsproviderconnection_ogr_gpkg.py">https://github.com/qgis/QGIS/blob/master/tests/src/python/test_qgsproviderconnection_ogr_gpkg.py</a></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Mar 31, 2022 at 6:09 PM Raymond Nijssen via QGIS-Developer <<a href="mailto:qgis-developer@lists.osgeo.org">qgis-developer@lists.osgeo.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi devs,<br>
<br>
I'm working on a plugin that connects to a custom table (without <br>
geometry) in a GPKG. When I'm sending queries to it, I keep on getting <br>
unexpected results. Somehow the id field is missing, sometimes it <br>
appears twice (!). And this seems to be different between QGIS 3.10 and <br>
3.25. (I think it changed since 3.22).<br>
<br>
Here is a piece of my code:<br>
<br>
<br>
fn = '/path/to/test.gpkg'<br>
md = QgsProviderRegistry.instance().providerMetadata('ogr')<br>
conn = md.createConnection(fn, {})<br>
<br>
q = 'select * from test_table;'<br>
qr = conn.executeSql(q)<br>
print(qr) # No id field in result<br>
<br>
<br>
<br>
Before diving into the QGIS code I'd like to check if this is the way to <br>
go. Or should i use another way to query that GPKG (SQLite) db?<br>
<br>
<br>
Kind regards,<br>
Raymond<br>
_______________________________________________<br>
QGIS-Developer mailing list<br>
<a href="mailto:QGIS-Developer@lists.osgeo.org" target="_blank">QGIS-Developer@lists.osgeo.org</a><br>
List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Alessandro Pasotti</div><div>QCooperative: <a href="https://www.qcooperative.net" target="_blank">www.qcooperative.net</a><br></div>ItOpen: <a href="http://www.itopen.it" target="_blank">www.itopen.it</a></div></div>