24 Commits

Author SHA1 Message Date
Alessandro Pasotti
a277cc6332 QgsAbstractDatabaseProviderConnection::QueryResult proper encapsulation
and rename to execSql
2020-12-21 10:43:51 +01:00
Alessandro Pasotti
84131e0cfc Connections API: executeSqlWithNames, return column names
This is mainly useful for Python, this way we can probably
avoid calling fields() and all related cost when all we need
is colum names for display.

I'm not very happy with the method name and I would probably just
drop the old signature for executeSql and replace it with the new
one, unfortunately is public API.

But if everybody is happy we could consider an API break.
2020-12-18 18:15:27 +01:00
Matthias Kuhn
6bd2b79b8f Fix doxygen command order 2020-10-22 11:31:55 +02:00
Alessandro Pasotti
b0189b4149 Return a proper QgsProviderConnectionException from python table()
Fixes #39151
2020-10-03 19:06:05 +10:00
Alessandro Pasotti
d54c3101ae Add feedback to executeSql
Fixes #38092 by adding an optional QgsFeedback argument to
the executeSql method and by implementing the PQCancel
method in the PG provider internals.

While the cancellation works well for all supported provider while
fetching results in the loop, the cancellation of a running query is now
implemented for the postgres provider connection only because the GPKG
and GDAL both rely on GDALDatasetExecuteSQL which cannot be interrupted.

This PR also introduce a few optimizations in the PG DB-Manager
code that should probably fix also other "slowness" issues that
were reported after 3.x during PG query execution.

A small UX change in th SQL dialog makes it evident to the user that
a cancellation request has been sent to the backend: the button text
is changed to "Cancellation requested, please wait..." so that for
provider connections that are not able to interrupt the running query
and must wait for the fetching loop to exit from the exeuteSql call
the user knows that something is happening and that a cancellation
request has been successfully sent.
2020-09-19 11:15:41 +02:00
Alessandro Pasotti
b1c371af58 Add static nativeTypes and remove ugly workaround 2020-07-16 10:49:10 +02:00
Alessandro Pasotti
1ac91c1f2e Add geom col capabilities and create spatial index 2020-07-16 09:40:18 +02:00
Alessandro Pasotti
d8a7531dc9 Connections API: add nativeTypes method 2020-07-14 15:25:20 +02:00
Alessandro Pasotti
93d9700708 Capture copies in lambda 2020-07-12 09:34:45 +02:00
Alessandro Pasotti
c3c87ce4dc Rename drop/add column to delete/add field
for consistency with othet Qgis classes
2020-07-11 14:19:30 +02:00
Alessandro Pasotti
f2858b24f2 Connections API: drop/add column
Also: expose it in the browser.

Implemented for:

- PG
- GPKG
- Spatialite
- MSSQL
2020-07-08 17:19:19 +02:00
Alessandro Pasotti
8ded0f146e Provider key getter and layer options 2020-07-07 08:30:54 +02:00
Alessandro Pasotti
dc67a4edec DB Connections API: add fields method -> column info 2020-07-06 16:57:47 +02:00
Nyall Dawson
cb883b0610 Add capability for determining whether a spatial index exists (implemented
for GPKG, spatialite) and deleting a spatial index (implemented for GPKG)
to database connection
2020-03-17 15:10:53 +10:00
Nyall Dawson
6a4b67f770 Add API for creating spatial indexes to QgsAbstractDatabaseProviderConnection 2020-03-17 15:10:53 +10:00
Nyall Dawson
f7731bc28f Add model for database tables from a connection
Optionally limited to a specific schema, if desired
2020-03-09 21:04:51 +10:00
Alessandro Pasotti
6c86055e57 PG: expose foreign tables 2020-03-07 13:55:29 +10:00
Juergen E. Fischer
edee4a3d10 spelling fixes (closes #32408) 2020-02-28 21:04:02 +01:00
Alessandro Pasotti
ce5405f136 Added since to new API methods 2019-10-28 09:25:40 +01:00
Alessandro Pasotti
aa92ef3576 DB connections API: add table() and tests
This method allows to retrieve information
about a single table.
2019-10-26 16:20:03 +02:00
Alessandro Pasotti
a070020cbb Add DB connection tableUri method
This allows to construct a data source URI string to load a table layer
from the DB connections.

!!
RASTER is still TODO
!!
2019-10-26 16:20:03 +02:00
Alessandro Pasotti
a092a82b52 New ctors for connections interface
Tries to make it clearer what are the use cases for the two
constructors (name and uri).
2019-08-21 15:45:21 +02:00
Juergen E. Fischer
19220b9e06 fix windows build including some warnings 2019-08-17 11:58:04 +02:00
Alessandro Pasotti
a3c4eb9947
Providers connections interface API
This is the implementation of the new DB connections API (grant proposal 2019).
Summary

The new API makes it available to QGIS core a new interface for provider connections and will allow to:

    replace the provider specific QgsSettings management in QGIS4 (save/load connections from the settings) NOT IN SCOPE FOR NOW.
    provide a unified API for common operations on DB connections:
        executeSql and get the results
        list tables names and properties and schemas
        create a new vector table (no rasters for now)
        create/rename/drop schemas and tables
        vacuum
       ....
2019-08-16 20:44:05 +02:00