Bug 137893 - Enhancement request: allow connection to multiple databases of different datasources to perform queries/reports on many tables
Summary: Enhancement request: allow connection to multiple databases of different data...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Base (show other bugs)
Version:
(earliest affected)
7.3.2.2 release
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
: 141132 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-10-31 07:43 UTC by LibreOffice fan user
Modified: 2023-12-18 15:21 UTC (History)
7 users (show)

See Also:
Crash report or crash signature:


Attachments
Screenshot of connection to 4 databases (34.19 KB, image/png)
2020-11-15 07:24 UTC, Robert Großkopf
Details

Note You need to log in before you can comment on or make changes to this bug.
Description LibreOffice fan user 2020-10-31 07:43:39 UTC
When making a connection to a database in Base, only one connection can be made per Base .odb file. It would be useful if *multiple* connections to be made, eg to allow the tables from 3 or 4 'external' databases to show in the 'Tables' pane, so that queries (and reports) joining data from tables of multiple databases could be made.
Comment 1 Robert Großkopf 2020-11-15 07:22:21 UTC
If you connect to an external database-server and there is more than one database you have the right to read and write data, you could do this in all the databases.

I will upload a screenshot for this  behavior. There are 4 different databases to see and also the system-databases from a mariadb. Connection is the native connection to the server and the name of the database I have written down in the connection is only "haushalt". If I do the same as another user, which has only rights to this specific database, only "haushalt" and "information_schema" will be shown.
Comment 2 Robert Großkopf 2020-11-15 07:24:00 UTC
Created attachment 167309 [details]
Screenshot of connection to 4 databases

See the different databases: "haushalt", "libretest", "physik" and "test"
Comment 3 LibreOffice fan user 2020-11-15 14:41:07 UTC
(In reply to Robert Großkopf from comment #2)
> Created attachment 167309 [details]
> Screenshot of connection to 4 databases
> 
> See the different databases: "haushalt", "libretest", "physik" and "test"

Of course this method allows to connect to different databases on the same server. But what if we had say a remote MySQL server with a database and some data, and another (remote or local) completely different data source eg HSQL or ODBC database that had other data we wanted to query; at present, I cannot see that it's possible to connect to two *completely* separate data sources within the same .odb file.
Comment 4 Robert Großkopf 2020-11-15 15:06:48 UTC
(In reply to LibreOffice fan user from comment #3)
> But what if we had say a remote MySQL server with a database and
> some data, and another (remote or local) completely different data source eg
> HSQL or ODBC database that had other data we wanted to query; at present, I
> cannot see that it's possible to connect to two *completely* separate data
> sources within the same .odb file.

The first problem would be: The *.odb-file could only connect to one source. You could connect to a different source through Basic macro:

DIM oDatabaseContext AS OBJECT
DIM oDatasource AS OBJECT
DIM oConnection AS OBJECT
oDatabaseContext = createUnoService("com.sun.star.sdb.DatabaseContext")
oDatasource = oDatabaseContext.getByName("Name of database on LO" or "file:///database.odb")
oConnection = oDatasource.GetConnection("","")

... but every source needs an *.odb-file to create the connection. You couldn't connect with the same driver to MariaDB and PostgreSQL, for example. You have to choose different drivers and this is what the *.odb-file does.

Queries over more than one database engine will only work in SQL-standard. So if you connect through macro you have to know much more about the different databases to get the right result.

I don't know if there is any GUI which allows to connect to different database engines in one surface.
Comment 5 Terrence Enger 2020-11-16 19:49:58 UTC
(In reply to Robert Großkopf from comment #4)
> I don't know if there is any GUI which allows to connect to different
> database engines in one surface.

The concept of a federated database has been around since the 1980's,
if I can believe wikipedia.

I do not know of any libre (or even merely gratis) project providing
database federation services.  I think it would be a really big job,
something more suitable for a project of its own rather than something
to do within LibreOffice.  IIRC, Brian Bruns has expressed an interest
in getting such a project going.
Comment 6 Alex Thurgood 2021-04-13 17:16:33 UTC
*** Bug 141132 has been marked as a duplicate of this bug. ***
Comment 7 Aprendiz 2022-05-19 13:12:37 UTC
I think this shouldn't be so difficult. In fact, from Calc you can add many dinamic tables (from different ODBC sources).

After that, if you create a new .odb you can use as source the .ods and then make querys with its dinamic tables.

Unfortunately, theese dinamic tables are read-only ( I think, I'm just beginning now with LibreOffice).

So, it would be "so easy" as deploying into Base the feature Calc has.
Comment 8 Robert Großkopf 2022-05-19 13:32:08 UTC
(In reply to Aprendiz from comment #7)
> I think this shouldn't be so difficult. In fact, from Calc you can add many
> dinamic tables (from different ODBC sources).

1. Calc tables are write protected. You could only use this solution for getting content from different sources for queries.
2. Queries with Calc could only contain one table as source. So you couldn't connect different tables to get results from different sources.

Multiple databases as source for queries and forms might be something people would need. So this is a valid enhancement request. Let us put this bug to NEW.