<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta content="text/html;charset=UTF-8" http-equiv="Content-Type"></head><body ><div style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt;"><div>Hey Aron,<br></div><div>                   I did explore that route, but I found out that it would fail when the user did not have administrator rights (or even if QGIS had not been ran as administrator on Windows).  Did you find it to be different?<br></div><div><br></div><div>Cheers,<br></div><div>Pedro<br></div><div><br></div><div><br></div><div class="zmail_extra" data-zbluepencil-ignore="true"><div><br></div><div id="Zm-_Id_-Sgn1">---- On Wed, 06 Apr 2022 03:28:09 +1000 <b>Aron Gergely <aron.gergely@rasterra.nl></b> wrote ----<br></div><div><br></div><blockquote style="border-left: 1px solid rgb(204, 204, 204); padding-left: 6px; margin: 0px 0px 0px 5px;"><div><p>Thank you, I checked out your plugin - yes that seems also a good
      way.<br> I already had the logic to detect, throw message, guide to dialog,
      etc... implemented similar to yours.<br> <br> But I wanted to let pip manage the actual package, so I went with
      the subprocess+pip route. Here is a minimum working example:<br></p><pre style="background-color: rgb(43,43,43);color: rgb(169,183,198);font-family: "JetBrains Mono", monospace;font-size: 9.8pt;"><span class="colour" style="color:rgb(204, 120, 50)">import </span>subprocess
<span class="colour" style="color:rgb(204, 120, 50)">import </span>sys


<span class="colour" style="color:rgb(204, 120, 50)">try</span>:
    subprocess.check_call((sys.executable<span class="colour" style="color:rgb(204, 120, 50)">, </span><span class="colour" style="color:rgb(106, 135, 89)">'-m'</span><span class="colour" style="color:rgb(204, 120, 50)">, </span><span class="colour" style="color:rgb(106, 135, 89)">'pip'</span><span class="colour" style="color:rgb(204, 120, 50)">, </span><span class="colour" style="color:rgb(106, 135, 89)">'install'</span><span class="colour" style="color:rgb(204, 120, 50)">, </span><span class="colour" style="color:rgb(106, 135, 89)">'h3<=3.99'</span>))
<span class="colour" style="color:rgb(204, 120, 50)">except </span>subprocess.CalledProcessError <span class="colour" style="color:rgb(204, 120, 50)">as </span>e:
    <span class="colour" style="color:rgb(204, 120, 50)">raise </span>e  <span class="colour" style="color:rgb(128, 128, 128)"># handle any errors here instead</span>
<br></pre><p>I connected it to a button in a dialog. And catch stdout, stderr
      and the exit code of the subprocess so I can show the user what is
      happening.<br> <br> Have not yet tried on other platforms than Linux. But
      sys.executable is there to solve the ambiguity of python
      executable path.<br> <br> <br> Best regards,<br> Aron<br> <br> <br></p><div class="x_-819925988moz-cite-prefix">On 01-04-2022 14:07, Pedro Camargo via
      QGIS-Developer wrote:<br></div><blockquote><div style="font-size: 10.0pt;font-family: Verdana, Arial, Helvetica, sans-serif;">Take
        a look at how it is done in the AequilibraE plugin.<br> <br> I basically ship the plugin without the binaries and create a
        menu item where the user can choose to download the binaries.<br> <br> Once downloaded, restarting the plugin allows it to identify the
        binaries and deactivate that menu item. <br> <br> Cheers,<br> Pedro <br id="x_-819925988br3"> <div id="x_-819925988content"><br>---- On Fri, 01 Apr 2022 05:00:02 +1000<b> <a class="x_-819925988moz-txt-link-abbreviated" href="mailto:qgis-developer-request@lists.osgeo.org" target="_blank" style="color: rgb(0, 0, 238);">qgis-developer-request@lists.osgeo.org</a> </b> wrote ----<br> <br> <blockquote style="border-left: 1.0px solid rgb(204,204,204);padding-left: 6.0px;margin-left: 5.0px;"><div>Send QGIS-Developer mailing list submissions to <br>     <a href="mailto:qgis-developer@lists.osgeo.org" target="_blank" class="x_-819925988moz-txt-link-freetext" style="color: rgb(0, 0, 238);">qgis-developer@lists.osgeo.org</a> <br> <br> To subscribe or unsubscribe via the World Wide Web, visit <br>     <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank" class="x_-819925988moz-txt-link-freetext" style="color: rgb(0, 0, 238);">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a> <br> or, via email, send a message with subject or body 'help'
              to <br>     <a href="mailto:qgis-developer-request@lists.osgeo.org" target="_blank" class="x_-819925988moz-txt-link-freetext" style="color: rgb(0, 0, 238);">qgis-developer-request@lists.osgeo.org</a> <br> <br> You can reach the person managing the list at <br>     <a href="mailto:qgis-developer-owner@lists.osgeo.org" target="_blank" class="x_-819925988moz-txt-link-freetext" style="color: rgb(0, 0, 238);">qgis-developer-owner@lists.osgeo.org</a> <br> <br> When replying, please edit your Subject line so it is more
              specific <br> than "Re: Contents of QGIS-Developer digest..." <br> <br> <br> Today's Topics: <br> <br> 1. Plugin dependency with binaries: 'best' way to guide
              user to <br> install? (Aron Gergely) <br> 2. Unexpected results from GPKG table query using
              executeSql() <br> (Raymond Nijssen) <br> 3. Re: Unexpected results from GPKG table query using <br> executeSql() (Alessandro Pasotti) <br> 4. Re: Unexpected results from GPKG table query using <br> executeSql() (Raymond Nijssen) <br> <br> <br> ---------------------------------------------------------------------- <br> <br> Message: 1 <br> Date: Thu, 31 Mar 2022 14:09:21 +0200 <br> From: Aron Gergely <<a href="mailto:aron.gergely@rasterra.nl" target="_blank" class="x_-819925988moz-txt-link-freetext" style="color: rgb(0, 0, 238);">aron.gergely@rasterra.nl</a>> <br> To: qgis-dev <<a href="mailto:qgis-developer@lists.osgeo.org" target="_blank" class="x_-819925988moz-txt-link-freetext" style="color: rgb(0, 0, 238);">qgis-developer@lists.osgeo.org</a>> <br> Subject: [QGIS-Developer] Plugin dependency with binaries:
              'best' way <br>     to guide user to install? <br> Message-ID: <5e3173ec<a target="_blank" class="x_-819925988moz-txt-link-freetext">-7b7e-64da-47d1-79d39edc1c10@rasterra.nl</a>> <br> Content-Type: text/plain; charset=UTF-8; format=flowed <br> <br> Hi All, <br> <br> What would be a good practice to handle 3rd party libs
              which can't be <br> shipped together with a plugin? <br> I am looking for the most user-friendly way and have an
              idea. <br> But thought I would bounce it off the collective wisdom
              here and see if <br> there are other/better ways. <br> <br> If we find a 'best' method I could PR an update to the
              QGIS docs or <br> PyQGIS cookbook, etc to preserve that knowledge. <br> <br> Bit of context: <br> I have a plugin that uses a 3rd party python library which
              has binaries. <br> I would like to submit this plugin to the official plugin
              repository. <br> According to <a href="https://plugins.qgis.org/publish/" target="_blank" class="x_-819925988moz-txt-link-freetext" style="color: rgb(0, 0, 238);">https://plugins.qgis.org/publish/</a> it's not allowed to ship <br> binaries it with the plugin. <br> In such case the above webpage recommends telling the end
              user to run <br> "pip.main(...)" from the python console to install missing
              libraries. <br> <br> I thought that's not user friendly and it's a pip hack
              (pip.main() is <br> meant to be internal). <br> Also, I want to handle the missing python module in my
              plugin <br> gracefully: check on plugin load if missing, if so, guide
              user to <br> resolve, preferably without having them write or copy any
              commands. <br> <br> The idea: <br> Using python's subprocess module from within the plugin to
              call the pip <br> CLI, which would install the package the usual pip way.
              Here's why: <br> - pip project recommends this way as best practice, warns
              against the <br> pip.main() <br> - user would not need to write or copy-paste commands <br> - could make this user friendly: wire it in the plugin
              code to a push <br> button and build it into a dialog e.g.;? if lib is missing
              on plugin load, <br> ? show a QMessageBox and let user open a dialog to
              resolve. In that <br> dialog would be the push button to trigger the pip install
              via subprocess. <br> <br> How would this play out multi-platform via subprocess, I
              have no idea of <br> yet - thought if the idea survived this thread, I'd go
              find out ;) <br> <br> Do you think this subprocess + pip is a good idea? <br> Would it be allowed for plugins in the official repository
              to behave as <br> such? <br> Anyone has other user-friendly ways of doing this? <br> <br> Best regards, <br> Aron <br> <br> <br> <br> ------------------------------ <br> <br> Message: 2 <br> Date: Thu, 31 Mar 2022 18:09:25 +0200 <br> From: Raymond Nijssen <<a href="mailto:r.nijssen@terglobo.nl" target="_blank" class="x_-819925988moz-txt-link-freetext" style="color: rgb(0, 0, 238);">r.nijssen@terglobo.nl</a>> <br> To: qgis-developer <<a href="mailto:qgis-developer@lists.osgeo.org" target="_blank" class="x_-819925988moz-txt-link-freetext" style="color: rgb(0, 0, 238);">qgis-developer@lists.osgeo.org</a>> <br> Subject: [QGIS-Developer] Unexpected results from GPKG
              table query <br>     using executeSql() <br> Message-ID: <bba11f52<a target="_blank" class="x_-819925988moz-txt-link-freetext">-a64a-6502-fbce-dbc986ba9391@terglobo.nl</a>> <br> Content-Type: text/plain; charset=UTF-8; format=flowed <br> <br> 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> <br> ------------------------------ <br> <br> Message: 3 <br> Date: Thu, 31 Mar 2022 18:15:00 +0200 <br> From: Alessandro Pasotti <<a href="mailto:apasotti@gmail.com" target="_blank" class="x_-819925988moz-txt-link-freetext" style="color: rgb(0, 0, 238);">apasotti@gmail.com</a>> <br> To: Raymond Nijssen <<a href="mailto:r.nijssen@terglobo.nl" target="_blank" class="x_-819925988moz-txt-link-freetext" style="color: rgb(0, 0, 238);">r.nijssen@terglobo.nl</a>> <br> Cc: qgis-developer <<a href="mailto:qgis-developer@lists.osgeo.org" target="_blank" class="x_-819925988moz-txt-link-freetext" style="color: rgb(0, 0, 238);">qgis-developer@lists.osgeo.org</a>> <br> Subject: Re: [QGIS-Developer] Unexpected results from GPKG
              table query <br>     using executeSql() <br> Message-ID: <br>     <CAL5Q670rrD--ZvEVDTtCWEqU1vZgUe7Nh<a target="_blank" class="x_-819925988moz-txt-link-freetext">+e58MLMDMQNPF9h1w@mail.gmail.com</a>> <br> Content-Type: text/plain; charset="utf-8" <br> <br> Hi Raymond, <br> <br> your code looks good. <br> <br> Can you provide a test file? <br> <br> There are some test in core here: <br> <a href="https://github.com/qgis/QGIS/blob/master/tests/src/python/test_qgsproviderconnection_ogr_gpkg.py" target="_blank" class="x_-819925988moz-txt-link-freetext" style="color: rgb(0, 0, 238);">https://github.com/qgis/QGIS/blob/master/tests/src/python/test_qgsproviderconnection_ogr_gpkg.py</a> <br> <br> <br> On Thu, Mar 31, 2022 at 6:09 PM Raymond Nijssen via
              QGIS-Developer < <br> <a href="mailto:qgis-developer@lists.osgeo.org" target="_blank" class="x_-819925988moz-txt-link-freetext" style="color: rgb(0, 0, 238);">qgis-developer@lists.osgeo.org</a>>
              wrote: <br> <br> > 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" class="x_-819925988moz-txt-link-freetext" style="color: rgb(0, 0, 238);">QGIS-Developer@lists.osgeo.org</a> <br> > List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank" class="x_-819925988moz-txt-link-freetext" style="color: rgb(0, 0, 238);">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a> <br> > Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank" class="x_-819925988moz-txt-link-freetext" style="color: rgb(0, 0, 238);">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a> <br> > <br> <br> <br> -- <br> Alessandro Pasotti <br> QCooperative: <a class="x_-819925988moz-txt-link-abbreviated" href="http://www.qcooperative.net" target="_blank" style="color: rgb(0, 0, 238);">www.qcooperative.net</a> <br> ItOpen: <a class="x_-819925988moz-txt-link-abbreviated" href="http://www.itopen.it" target="_blank" style="color: rgb(0, 0, 238);">www.itopen.it</a> <br> -------------- next part -------------- <br> An HTML attachment was scrubbed... <br> URL: <<a href="http://lists.osgeo.org/pipermail/qgis-developer/attachments/20220331/ad1ec7b7/attachment-0001.html" target="_blank" class="x_-819925988moz-txt-link-freetext" style="color: rgb(0, 0, 238);">http://lists.osgeo.org/pipermail/qgis-developer/attachments/20220331/ad1ec7b7/attachment-0001.html</a>> <br> <br> ------------------------------ <br> <br> Message: 4 <br> Date: Thu, 31 Mar 2022 18:52:48 +0200 <br> From: Raymond Nijssen <<a href="mailto:r.nijssen@terglobo.nl" target="_blank" class="x_-819925988moz-txt-link-freetext" style="color: rgb(0, 0, 238);">r.nijssen@terglobo.nl</a>> <br> To: Alessandro Pasotti <<a href="mailto:apasotti@gmail.com" target="_blank" class="x_-819925988moz-txt-link-freetext" style="color: rgb(0, 0, 238);">apasotti@gmail.com</a>> <br> Cc: qgis-developer <<a href="mailto:qgis-developer@lists.osgeo.org" target="_blank" class="x_-819925988moz-txt-link-freetext" style="color: rgb(0, 0, 238);">qgis-developer@lists.osgeo.org</a>> <br> Subject: Re: [QGIS-Developer] Unexpected results from GPKG
              table query <br>     using executeSql() <br> Message-ID: <87330c53<a target="_blank" class="x_-819925988moz-txt-link-freetext">-a8a5-6e07-dd6e-006fcdd7710f@terglobo.nl</a>> <br> Content-Type: text/plain; charset=UTF-8; format=flowed <br> <br> Hi Alessandro, <br> <br> Thanks for your reply. Will share data and a test script
              with you privately. <br> <br> Raymond <br> <br> <br> On 31-03-2022 18:15, Alessandro Pasotti wrote: <br> > Hi Raymond, <br> > <br> > your code looks good. <br> > <br> > Can you provide a test file? <br> > <br> > There are some test in core here: <br> > <a href="https://github.com/qgis/QGIS/blob/master/tests/src/python/test_qgsproviderconnection_ogr_gpkg.py" target="_blank" class="x_-819925988moz-txt-link-freetext" style="color: rgb(0, 0, 238);">https://github.com/qgis/QGIS/blob/master/tests/src/python/test_qgsproviderconnection_ogr_gpkg.py</a> <br> > <<a href="https://github.com/qgis/QGIS/blob/master/tests/src/python/test_qgsproviderconnection_ogr_gpkg.py" target="_blank" class="x_-819925988moz-txt-link-freetext" style="color: rgb(0, 0, 238);">https://github.com/qgis/QGIS/blob/master/tests/src/python/test_qgsproviderconnection_ogr_gpkg.py</a>> <br> > <br> > <br> > On Thu, Mar 31, 2022 at 6:09 PM Raymond Nijssen via
              QGIS-Developer <br> > <<a href="mailto:qgis-developer@lists.osgeo.org" target="_blank" class="x_-819925988moz-txt-link-freetext" style="color: rgb(0, 0, 238);">qgis-developer@lists.osgeo.org</a> <mailto:<a href="mailto:qgis-developer@lists.osgeo.org" target="_blank" class="x_-819925988moz-txt-link-freetext" style="color: rgb(0, 0, 238);">qgis-developer@lists.osgeo.org</a>>> <br> > wrote: <br> > <br> > 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 <br> > 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" class="x_-819925988moz-txt-link-freetext" style="color: rgb(0, 0, 238);">QGIS-Developer@lists.osgeo.org</a> <mailto:<a href="mailto:QGIS-Developer@lists.osgeo.org" target="_blank" class="x_-819925988moz-txt-link-freetext" style="color: rgb(0, 0, 238);">QGIS-Developer@lists.osgeo.org</a>> <br> > List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank" class="x_-819925988moz-txt-link-freetext" style="color: rgb(0, 0, 238);">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a> <br> > <<a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank" class="x_-819925988moz-txt-link-freetext" style="color: rgb(0, 0, 238);">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a>> <br> > Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank" class="x_-819925988moz-txt-link-freetext" style="color: rgb(0, 0, 238);">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a> <br> > <<a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank" class="x_-819925988moz-txt-link-freetext" style="color: rgb(0, 0, 238);">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a>> <br> > <br> > <br> > <br> > -- <br> > Alessandro Pasotti <br> > QCooperative: <a class="x_-819925988moz-txt-link-abbreviated" href="http://www.qcooperative.net" target="_blank" style="color: rgb(0, 0, 238);">www.qcooperative.net</a> <<a href="https://www.qcooperative.net" target="_blank" class="x_-819925988moz-txt-link-freetext" style="color: rgb(0, 0, 238);">https://www.qcooperative.net</a>> <br> > ItOpen: <a class="x_-819925988moz-txt-link-abbreviated" href="http://www.itopen.it" target="_blank" style="color: rgb(0, 0, 238);">www.itopen.it</a> <<a href="http://www.itopen.it" target="_blank" class="x_-819925988moz-txt-link-freetext" style="color: rgb(0, 0, 238);">http://www.itopen.it</a>> <br> <br> <br> ------------------------------ <br> <br> Subject: Digest Footer <br> <br> _______________________________________________ <br> QGIS-Developer mailing list <br> <a href="mailto:QGIS-Developer@lists.osgeo.org" target="_blank" class="x_-819925988moz-txt-link-freetext" style="color: rgb(0, 0, 238);">QGIS-Developer@lists.osgeo.org</a> <br> List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank" class="x_-819925988moz-txt-link-freetext" style="color: rgb(0, 0, 238);">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a> <br> Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank" class="x_-819925988moz-txt-link-freetext" style="color: rgb(0, 0, 238);">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a> <br> <br> <br> ------------------------------ <br> <br> End of QGIS-Developer Digest, Vol 197, Issue 39 <br> *********************************************** <br></div></blockquote></div></div><br><br><pre class="x_-819925988moz-quote-pre">_______________________________________________
QGIS-Developer mailing list
<a class="x_-819925988moz-txt-link-abbreviated" href="mailto:QGIS-Developer@lists.osgeo.org" target="_blank" style="color: rgb(0, 0, 238);">QGIS-Developer@lists.osgeo.org</a>
List info: <a class="x_-819925988moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank" style="color: rgb(0, 0, 238);">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a>
Unsubscribe: <a class="x_-819925988moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank" style="color: rgb(0, 0, 238);">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a>
<br></pre></blockquote><div class="x_-819925988moz-signature">-- <br> Kind Regards,<br> <br> Aron Gergely<br> +31 (0) 6 38 70 97 66<br> <br> <b>Rasterra</b> | <a class="x_-819925988moz-txt-link-abbreviated" href="http://www.rasterra.nl" target="_blank" style="color: rgb(0, 0, 238);">www.rasterra.nl</a><a><br></a></div></div></blockquote></div><div><br></div></div><br></body></html>