[QGIS-Developer] Lazy question about using views in GeoPackages

Bo Victor Thomsen bo.victor.thomsen at gmail.com
Fri May 26 03:52:56 PDT 2023


Hi list -

Recently, I've begun experimenting with creating spatial view's of 
base-tables inside GeoPackages. A Geopackage is basically a SQLite file 
containing  spatial data- and meta-tables with specific structures of 
information about the spatial tables.

So it's possible to create a permanent view of a table (or tables) in 
the GeoPackage by making a functioning SQL select statement and 
prefixing it with "CREATE VIEW /view_name/ AS .. /the select statement/ 
.. (This is database 101 knowledge)

However, if you want to expose those views as "read-only" tables/layers 
for "non-sql-using" QGIS users  you have to update several meta-tables 
in the GeoPackage: /gpkg_contents/, /gpkg_geometry_columns/ and maybe 
/gpkg_ogr_contents/.

I'm brainstorming with myself about making some kind of automated 
updating of the meta-tables with information about the views created. 
Maybe some python code and maybe creating triggers for the base table to 
handle data changes regarding the extend of the data.

And now (at last !!) my question: I haven't been able to find very much 
information about this subject using Google or StackExchange. So.. Is 
there some existing code / plugin / information so I don't have to 
"reinvent the wheel" ?


-- 
Med venlig hilsen / Best regards

Bo Victor Thomsen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20230526/b29f1266/attachment.htm>


More information about the QGIS-Developer mailing list