Export base queries to .sql

I have accumulated a number of queries in libreoffice base. The large number of queries is causing the queries window to appear cluttered and thereby I’m don’t have overview anymore. For this reason I decided I wanted to store my queries as .sql files and run them through mysql workbench. In that way I can order the queries (.sql files) in folders and keep a better overview.

One way to move the queries to .sql-files is by opening every base query in sql-view and copy-pasting the written commands. However, because that would be a labour intensive, repetitive job, I’m wondering if there is a way to do a batch export of base queries to .sql files.

I’m using Base 6.0.6 on Xubuntu 18.04


If you ‘unzip’ (archive manager) the .odb, in the main folder is a file “content.xml”. Open this file with a browser and you will find all the queries in one section - db.queries

From there you it should be a bit easier to copy & paste.

As for exporting to .sql files, you can most likely do this by writing a macro to read the query statement & then write each to a file. Not sure which involves more work.

thanks, I tried the unzipping, it saved me some time.

Not a batch export method but I wonder if this is any less labour intensive:
"You copy a table from Base to a new Calc sheet, then you can save or export the data to any file format that Calc supports.

  1. Open the database file that contains the database table to be exported. Click Tables to view the tables, or click Queries to view the queries.
  2. Choose File - New - Spreadsheet.
  3. In the Base window, right-click the name of the table to export. Choose Copy from the context menu.
  4. Click cell A1 in the new Calc window, then choose Edit - Paste.

Now you can save or export the data to many file types."

@John99 I believe the question is about the Query text and not the tables in Base.

Ratslinger is correct


There is an extension for this.

I haven’t tried it. The documentation seems to be complete and well detailed.


@PYS BaseDocumenter is only for HSQLDB currently. Question deals with MySQL. Have personally tried in Linux & it was unacceptable to me.

Hi @Ratslinger

Question deals with MySQL

I should have seen it indeed. Thank you for the feedback…