Regularly, I have to load layers from SQLite databases through Spatialite in Qgis 3.16 and perform some algorithms. Extension of these SQLite databases is not *.sqlite but another format (proprietary).
My step 1) is to load layers from SQLite database in Qgis through Spatialite. My step 2) is the use of models to perform algorithms on these layers.
I would like to load databases layers directly from models algorithms, thus to avoid this manual step of loading layers with Spatialite.
I tried many ways to reach this goal, and finally circumvented this issue. Inspired from Load lines from .OSM in Processing Modeler, I am now able to load temporary layers with the appropriate CRS from SQLite database into Qgis directly. Here is the scheme of the model:
Due to the "String concatenation" algorithm, I may not be able to use this model scheme to load layers for some databases (the names of the layers could slightly change). Using the QGIS documentation and Stack Exchange Q&As, I am now able to do some SQL Queries with DB Manager. I think that the use of SQL Queries could solve this issue, also may be easier and faster. However, I did not find an algorithm or a way to execute AND load SQL from a SQLite database, as the algorithm "PostgreSQL execute and load SQL" do for Postgis database.
If I understood it correctly, I also need to find a way to declare in an SQL query:
-
- an Unique ID field name
-
- a Geometry field name
for each layer. Is there a way to do it? Please be clear, I'm still not very comfortable with SQL Queries.