Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No strong opinion, can we provide schema in this screenshot?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a screenshot for importing to gpkg; the schema label should have been deactivated also (will be fixed in qgis/QGIS#64089)

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
65 changes: 65 additions & 0 deletions docs/user_manual/plugins/core_plugins/plugins_db_manager.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,76 @@ Double clicking on an entry will add the string to the SQL window.
to use.


Import Vector Layer
---------------------------

You can import layer or file into your database. Here are the parameters you can set
for the import process:
Comment on lines +114 to +115
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make a reference to this section ?


* :guilabel:`Input`: Select the layer or file to import. Using the dropdown menu,
select from the list of loaded layers in QGIS or click on the
:guilabel:`...` button to select a file from disk.
Check the |checkbox| :guilabel:`Import only selected features` to import only the selected
features of the layer.
* :guilabel:`Output table`: Choose the :guilabel:`Schema` and provide a name for the new table.
* :guilabel:`Options`: Here are some options for the import process:

- |checkbox| :guilabel:`Primary key`: Provide naming for the primary key field.
By default, it is named ``id``.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(need to check but) does this not default to gid for PostgreSQL?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id on my end

- |checkbox| :guilabel:`Geometry column`: Provide naming for the geometry column.
By default, it is named ``geom``.
- |checkbox| :guilabel:`Source SRID`: Define the SRID for the geometry column.
By default, it uses the layer's CRS.
- |checkbox| :guilabel:`Target SRID`: Define the target SRID to reproject the geometries
during the import process. By default, it uses the layer's CRS.
- |checkbox| :guilabel:`Encoding`: Define the encoding of the source data. By default, it uses ``Automatic``.
It is QGIS's automatic detection mode that attempts to guess the file's character encoding based on available metadata or system locale.
- |checkbox| :guilabel:`Replace destination table (if exists)`: If a table with the same name already exists in the selected schema,
it will be replaced.
- |checkbox| :guilabel:`Do not promote to multi-part`: Geometries will be imported as single-part geometries.
- |checkbox| :guilabel:`Convert field names to lower case`: All field names will be converted to lower case.
- |checkbox| :guilabel:`Create spatial index`: A spatial index will be created on the geometry column after import.
- |checkbox| :guilabel:`Comment`: Add comments to the table and columns based on the source layer's metadata. You can also add or edit comments manually.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand. Existing comments in source layer are made available in this field (before you could edit)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to import a layer that has no comment. I was expecting that behavior but after testing it today using layer with existing comment apparently it doesnt work that way (or bug?), we can only add it not edit the existing. It's giving me idea to file a feature request. So that when we try to import vector layer from canvas, it will show us existing comment that is editable. @DelazJ

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is implemented, but for PostGIS (see qgis/QGIS#60875 unless I misunderstand)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that’s correct. As far as I know, table comments are supported only for PostGIS. However, editing existing comments only works when the layer is imported by dragging it from the Layer Panel into the Browser Panel. The same does not work when importing through DB Manager, existing comments are not detected or shown there. 🤔 @DelazJ


.. figure:: img/db_manager_import.png
:align: center
:width: 400px

Importing a vector layer into a spatial database using DB Manager


Export to Vector File
---------------------------

To export a table from your database to a vector file, select
the desired :guilabel:`Format` and :guilabel:`Save as` location.
Under :guilabel:`Options`, you can set the following parameters:

* |checkbox| :guilabel:`Source SRID`: Define the source SRID of the geometry column.
By default, it uses the layer's CRS.
* |checkbox| :guilabel:`Target SRID`: Define the target SRID to reproject the geometries
during the export process. By default, it uses the layer's CRS.
* |checkbox| :guilabel:`Encoding`: Define the encoding of the output data.
* |checkbox| :guilabel:`Replace destination table (if exists)`: If a table with the same name already exists at the selected location,
it will be replaced.

.. figure:: img/db_manager_export.png
:align: center
:width: 400px

Exporting a table to a vector file using DB Manager



.. Substitutions definitions - AVOID EDITING PAST THIS LINE
This will be automatically updated by the find_set_subst.py script.
If you need to create a new substitution manually,
please add it also to the substitutions.txt file in the
source folder.


.. |checkbox| image:: /static/common/checkbox.png
:width: 1.5em
.. |dbManager| image:: /static/common/dbmanager.png
:width: 1.5em