<html><head></head><body><div class="ydp9d990435yahoo-style-wrap" style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:13px;"><div></div>
        <div dir="ltr" data-setdir="false">Hi Michael,</div><div dir="ltr" data-setdir="false"><br></div><div dir="ltr" data-setdir="false">I think l can see where the problem lies with model builder. Temporary tables only exist in the database connection that created them. So the difficulty is passing the connection from one tool to the next in your model.  I am not sure there is a way to do that. If you want to stick with model builder you may want to consider having your model create a table using the filters, and populate it with the filtered data. Then the user can edit it as they see fit and when they are done, whatever code you were planning to use to make the changes permanent would also drop the "not so temporary" table. Obviously you would need to periodically find and drop old tables that did not get dropped by their creators.</div><div dir="ltr" data-setdir="false"><br></div><div dir="ltr" data-setdir="false">Python should be able to work with temporary tables, but you might have to build the whole thing in python to maintain the connection. I do not know enough about how QGIS interacts with the database, if each layer has a connection that is maintained until the QGIS project is closed, or if the connection is reestablished periodically, for example when the extent changes.</div><div dir="ltr" data-setdir="false"><br></div><div dir="ltr" data-setdir="false">-Thayer</div><div dir="ltr" data-setdir="false"><br></div><div><br></div></div><div id="ydpd6d7f89yahoo_quoted_0496856215" class="ydpd6d7f89yahoo_quoted"><div style="font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:13px;color:#26282a;"><div><div dir="ltr">Date: Tue, 4 May 2021 08:50:16 +0000<br></div><div dir="ltr">From: Michael Gieding <<a href="mailto:michael.gieding@live.de" rel="nofollow" target="_blank">michael.gieding@live.de</a>><br></div><div dir="ltr">To: "<a href="mailto:qgis-user@lists.osgeo.org" rel="nofollow" target="_blank">qgis-user@lists.osgeo.org</a>" <<a href="mailto:qgis-user@lists.osgeo.org" rel="nofollow" target="_blank">qgis-user@lists.osgeo.org</a>><br></div><div dir="ltr">Subject: Re: [Qgis-user] Loading filtered database table as temp layer<br></div><div dir="ltr">Message-ID:<br></div><div dir="ltr">    <<a href="mailto:AS8P191MB17524CF81C1E020295B1D705E55A9@AS8P191MB1752.EURP191.PROD.OUTLOOK.COM" rel="nofollow" target="_blank">AS8P191MB17524CF81C1E020295B1D705E55A9@AS8P191MB1752.EURP191.PROD.OUTLOOK.COM</a>><br></div><div dir="ltr">    <br></div><div dir="ltr">Content-Type: text/plain; charset="us-ascii"<br></div><div dir="ltr"><br></div><div dir="ltr">Hello Thayer,<br></div><div dir="ltr"><br></div><div dir="ltr">thank you for your reply. I try to make it a bit more clear.<br></div><div dir="ltr"><br></div><div dir="ltr">I've got a PostgreSQL-table with lots of points which have attributes like "name" and "date".<br></div><div dir="ltr">In our scenario the users must be able to work with a filtered subset of points from this table.<br></div><div dir="ltr">Ideally they should be able to delete or edit these points without changing the original data.<br></div><div dir="ltr">So my idea of a workflow is to add the database table to a QGIS project, add a flilter like<br></div><div dir="ltr">"name='xyz' and date='2021-05-01', mark all loaded points, copy them and insert them as<br></div><div dir="ltr">a new temporary layer.<br></div><div dir="ltr">With that you can safely work with that new layer until you have got the desired result. No<br></div><div dir="ltr">changes in the databse are necessary.<br></div><div dir="ltr">In my opinion this is nothing for unexperienced users and needs to much clicks. So I'm looking<br></div><div dir="ltr">for a solution where the user can open a kind of gui where she can add the filter parameters<br></div><div dir="ltr">and with "ok" the temporary layer is automatically generated.<br></div><div dir="ltr">To prevent to program an own plugin I tried to solve this with the modelbuilder. In the moment<br></div><div dir="ltr">it works to create a new layer which is the original filtered database table. So it's more like a<br></div><div dir="ltr">sqlstatement loaded to QGIS from the database manager. But I was not able to create a<br></div><div dir="ltr">temporary layer as output from the modelscript.<br></div><div dir="ltr">Maybe there is already a plugin out there which does something like this or could be a good<br></div><div dir="ltr">starting point for an own plugin.<br></div><div dir="ltr"><br></div><div dir="ltr"><br></div><div dir="ltr"><br></div><div dir="ltr">Thanks,<br></div><div dir="ltr"><br></div><div dir="ltr">Michael Gieding<br></div><div dir="ltr"><br></div><div dir="ltr"><br></div></div>
            </div>
        </div></body></html>