LabPlot/ImportExport/ImportFromSQLDatabases: Difference between revisions

From KDE UserBase Wiki
(Created page with "LabPlot can read and import data from SQL databases. The supported databases are those that are covered by Qt SQL. http://doc.qt.io/qt-5/sql-driver.html 1. Import dialog Sim...")
 
No edit summary
 
(6 intermediate revisions by one other user not shown)
Line 1: Line 1:
LabPlot can read and import data from SQL databases. The supported databases are those that are covered by Qt SQL.
LabPlot can read and import data from SQL databases. The supported databases are those that are covered by [http://doc.qt.io/qt-5/sql-driver.html Qt SQL].
http://doc.qt.io/qt-5/sql-driver.html


1. Import dialog
Similar to the import from files, there is a dialog for importing from databases that guides the user through the process of selection and import of the relevant data.
Similar to the already existing “Import dialog” for files, there is now a new dialog for importing from the databases that guides the user through the process of selection and import of the relevant data.
[[File:LabPlot Import SQL dialog.png |500px|thumb|center]]


When opening this dialog for the first time, it's empty and the first step is to configure the connection to your database by clicking on the button "Manage connection" (red-highlighted on the screenshot above).
When opening this dialog for the first time, it's empty and the first step is to configure the connection to the database by clicking on the button "Manage connection" (red-highlighted on the screenshot above).


2. In the "Connection Manager" dialog select the proper database driver and provide the relevant settings like the host, the port number, the credentials and the actual name of the database. In case the SQLite database is used, the connection is simply the path to the database file.
In the "Connection Manager" dialog select the proper database driver and provide the relevant settings like the host, the port number, the credentials and the actual name of the database on the server:
[[File:LabPlot Import SQL new connection.png |500px|thumb|center]]


3. After all the connections settings were specified, click on the "Test" button to make sure LabPlot can connect successfuly to the database:
In case the SQLite database is used, the connection is simply the path to the database file:
[[File:LabPlot Import SQL new sqlite connection.png |500px|thumb|center]]
 
After all the connections settings were specified, click on the "Test" button to make sure LabPlot can connect successfully to the database:
[[File:LabPlot Import SQL test connection.png |500px|thumb|center]]


Note, once a connection is configured and saved, the user can select it in the import dialog for future imports and there is no need to go through the configuration steps again. Also, it is possible to manage multiple connections to different databases.  
Note, once a connection is configured and saved, the user can select it in the import dialog for future imports and there is no need to go through the configuration steps again. Also, it is possible to manage multiple connections to different databases.  


The dialog supports the user with the navigation through the available tables in the database and with a preview of the table data:
[[File:LabPlot Import SQL table preview.png |500px|thumb|center]]


4. Import either complete tables or results of a SQL query
Furthermore, it is also possible to import the result of a custom SQL query and import its result set. Provide the SQL query and click on the "Refresh" button in the preview section of the import dialog to execute the query and to preview its result:
[[File:LabPlot Import SQL query preview.png |500px|thumb|center]]


The dialog supports the user with the navigation through the available database tables and with a preview of the table data:
Once the selection of the relevant data is finalized, specify the data container to import into and click on the "Ok" button. After the import is done, the data is ready to be used. In the example below, the result of the query calculating the average salaries per departments based on the test data from [https://github.com/datacharmer/test_db "Employees"] was visualized after the import:
[[File:LabPlot Import SQL final result.png |500px|thumb|center]]


==Import data from SQL databases==


Furthermore, it is also possible to import the result of a custom SQL query and import its result set:
See the video on how to '''import data from SQL databases''' in LabPlot.


5. finale results
{{#ev:youtube|nntP1okY0zg|800|center}}

Latest revision as of 10:00, 17 August 2023

LabPlot can read and import data from SQL databases. The supported databases are those that are covered by Qt SQL.

Similar to the import from files, there is a dialog for importing from databases that guides the user through the process of selection and import of the relevant data.

When opening this dialog for the first time, it's empty and the first step is to configure the connection to the database by clicking on the button "Manage connection" (red-highlighted on the screenshot above).

In the "Connection Manager" dialog select the proper database driver and provide the relevant settings like the host, the port number, the credentials and the actual name of the database on the server:

In case the SQLite database is used, the connection is simply the path to the database file:

After all the connections settings were specified, click on the "Test" button to make sure LabPlot can connect successfully to the database:

Note, once a connection is configured and saved, the user can select it in the import dialog for future imports and there is no need to go through the configuration steps again. Also, it is possible to manage multiple connections to different databases.

The dialog supports the user with the navigation through the available tables in the database and with a preview of the table data:

Furthermore, it is also possible to import the result of a custom SQL query and import its result set. Provide the SQL query and click on the "Refresh" button in the preview section of the import dialog to execute the query and to preview its result:

Once the selection of the relevant data is finalized, specify the data container to import into and click on the "Ok" button. After the import is done, the data is ready to be used. In the example below, the result of the query calculating the average salaries per departments based on the test data from "Employees" was visualized after the import:

Import data from SQL databases

See the video on how to import data from SQL databases in LabPlot.