Base de données¶
Export to PostgreSQL¶
Exports a vector layer to a PostgreSQL database. Prior to this a connection between QGIS and the PostgreSQL database has to be created (see eg Créer une connexion enregistrée).
Paramètres¶
Label |
Name |
Type |
Description |
---|---|---|---|
Layer to import |
|
[vector: any] |
Vector layer to add to the database |
Database (connection name) |
|
[string] |
Name of the database connection (not the database name). Existing connections will be shown in the combobox. |
Schema (schema name) Optional |
|
[string] Default: “public” |
Name of the schema to store the data. It can be a new one or already exist. |
Table to import to (leave blank to use layer name) Optional |
|
[string] Default: “” |
Defines a table name for the imported vector file. If nothing is added, the layer name will be used. |
Primary key field Optional |
|
[tablefield: any] |
Sets the primary key field from an existing field in the vector layer. A column with unique values can be used as Primary key for the database. |
Geometry column |
|
[string] Default: “geom” |
Définit le nom de la colonne géométrique dans la nouvelle table PostGIS. L’information géométrique des entités est enregistrée dans cette colonne. |
Encoding Optional |
|
[string] Default: “UTF-8” |
Defines the encoding of the output layer |
Overwrite |
|
[boolean] Default: True |
If the specified table exists, setting this option to
|
Create spatial index |
|
[boolean] Default: True |
Specifies whether to create a spatial index or not |
Convert field names to lowercase |
|
[boolean] Default: True |
Converts the field names of the input vector layer to lowercase |
Drop length constraint on character fields |
|
[boolean] Default: False |
Should length constraints on character fields be dropped or not |
Create single-part geometries instead of multi-part |
|
[boolean] Default: False |
Should the features of the output layer be single-part instead of multi-part. By default the existing geometries information are preserved. |
Sorties¶
The algorithm has no output.
Export to SpatiaLite¶
Exports a vector layer to a SpatiaLite database. Prior to this a connection between QGIS and the SpatiaLite database has to be created (see eg Couches SpatiaLite).
Paramètres¶
Label |
Name |
Type |
Description |
---|---|---|---|
Layer to import |
|
[vector: any] |
Vector layer to add to the database |
File database |
|
[vector: any] |
The SQLite/SpatiaLite database file to connect to |
Table to import to (leave blank to use layer name) Optional |
|
[string] Default: “” |
Defines the table name for the imported vector file. If nothing is specified, the layer name will be used. |
Primary key field Optional |
|
[tablefield: any] |
Use a field in the input vector layer as the primary key |
Geometry column |
|
[string] Default: “geom” |
Defines the name of the geometry column in the new SpatiaLite table. Geometry information for the features is stored in this column. |
Encoding Optional |
|
[string] Default: “UTF-8” |
Defines the encoding of the output layer |
Overwrite |
|
[boolean] Default: True |
If the specified database exists, setting this option to
|
Create spatial index |
|
[boolean] Default: True |
Specifies whether to create a spatial index or not |
Convert field names to lowercase |
|
[boolean] Default: True |
Convert the field names of the input vector layer to lowercase |
Drop length constraint on character fields |
|
[boolean] Default: False |
Should length constraints on character fields be dropped or not |
Create single-part geometries instead of multi-part |
|
[boolean] Default: False |
Should the features of the output layer be single-part instead of multi-part. By default the existing geometries information are preserved. |
Sorties¶
The algorithm has no output.
Package layers¶
Adds layers to a GeoPackage.
If the GeoPackage exists and Overwrite existing GeoPackage
is checked, it will be overwritten (removed and recreated).
If the GeoPackage exists and Overwrite existing GeoPackage
is not checked, the layers will be appended to the GeoPackage.
Paramètres¶
Label |
Name |
Type |
Description |
---|---|---|---|
Input layers |
LAYERS |
[vector: any] [list] |
The (vector) layers to import into the GeoPackage.
Raster layers are not supported. If a raster layer is
added, a
|
Overwrite existing GeoPackage |
OVERWRITE |
[boolean] Default: False |
If the specified GeoPackage exists, setting this option to
|
Destination GeoPackage |
OUTPUT |
[file] |
If not specified the GeoPackage will be saved in the temporary folder. |
Sorties¶
Label |
Name |
Type |
Description |
---|---|---|---|
Layers within new package |
OUTPUT_LAYERS |
[string] [list] |
The list of layers added to the GeoPackage. |
PostgreSQL execute and load SQL¶
Allows a SQL database query to be performed on a PostgreSQL database connected to QGIS and loads the result. The algorithm won’t create any new layer: it is designed to run queries on the layer itself.
Example
For all features / rows in a PostGIS / PostgreSQL table (« your_table »), set the value of an existing field (« field_to_update ») to a given value (
20
). The SQL query string:UPDATE your_table SET field_to_update=20;
- Create a new
area
column and calculate the area of each feature with the
ST_AREA
PostGIS function.
-- Create the new column "area" in a table named "your_table" ALTER TABLE your_table ADD COLUMN area double precision; -- Update the "area" column of each feature with the its area: UPDATE your_table SET area=ST_AREA(geom);
- Create a new
Voir aussi
PostgreSQL execute SQL, Exécuter SQL, SpatiaLite execute SQL
Paramètres¶
Label |
Name |
Type |
Description |
---|---|---|---|
Database (connection name) |
|
[string] |
The database connection (not the database name). Existing connections will be shown in the combobox. |
SQL query |
|
[string] |
Defines the SQL query, for example
|
Unique ID field name |
|
[string] Default: id |
Sets the primary key field (a column in the result table) |
Geometry field name Optional |
|
[string] Default: “geom” |
Name of the geometry column (a column in the result table) |
Sorties¶
Label |
Name |
Type |
Description |
---|---|---|---|
SQL layer |
|
[vector: any] |
The resulting vector layer to be loaded into QGIS. |
PostgreSQL execute SQL¶
Allows a SQL database query to be performed on a PostgreSQL database connected to QGIS. The algorithm won’t create any new layer: it is designed to run queries on the layer itself.
Example
For all features / rows in a PostGIS / PostgreSQL table (« your_table »), set the value of an existing field (« field_to_update ») to a given value (
20
). The SQL query string:UPDATE your_table SET field_to_update=20;
- Create a new
area
column and calculate the area of each feature with the
ST_AREA
PostGIS function.
-- Create the new column "area" in a table named "your_table" ALTER TABLE your_table ADD COLUMN area double precision; -- Update the "area" column of each feature with the its area: UPDATE your_table SET area=ST_AREA(geom);
- Create a new
Paramètres¶
Label |
Name |
Type |
Description |
---|---|---|---|
Database (connection name) |
|
[string] |
The database connection (not the database name). Existing connections will be shown in the combobox. |
SQL query |
|
[string] |
Defines the SQL query, for example
|
Sorties¶
No output is created. The SQL query is executed in place.
SpatiaLite execute SQL¶
Allows a SQL database query to be performed on a SpatiaLite database connected to QGIS. The algorithm won’t create any new layer: it is designed to run queries on the layer itself.
Voir aussi
PostgreSQL execute SQL, Exécuter SQL
For some SQL query examples see PostGIS SQL Query Examples.
Paramètres¶
Label |
Name |
Type |
Description |
---|---|---|---|
File Database |
|
[vector] Default: not set |
The SQLite/SpatiaLite database file to connect to |
SQL query |
|
[string] Default: “” |
Defines the SQL query, for example
|
Sorties¶
No output is created. The SQL query is executed in place.