Generate sql table dump from Base

Hi, is there a simple way to generate an SQL dump from a Base program?
I am running Libreoffice 6.3 on Windows and/or Lubuntu1604, and from the .odb file would like to generate an SQL dump, that I can then feed into another database. Below an example of a similar dump from an MS Access file:

CREATE DATABASE IF NOT EXISTS `movedb`;
USE `movedb`;

#
# Table structure for table 'tbl_106'
#

DROP TABLE IF EXISTS `tbl_106`;

CREATE TABLE `tbl_106` (
  `ID` INTEGER NOT NULL AUTO_INCREMENT, 
  `VOL` INTEGER, 
  `REC` INTEGER DEFAULT 0, 
  `PAG` INTEGER DEFAULT 0, 
  `INDX` VARCHAR(50), 
  `FOTO` INTEGER DEFAULT 0, 
  `FOTOLINK` LONGTEXT, 
  `ANNO` INTEGER, 
  `DATAIMMAGINE` DATETIME, 
  `TIPO` VARCHAR(50), 
  `CHIESA` VARCHAR(50), 
  `DA` INTEGER DEFAULT 0, 
  `A` INTEGER DEFAULT 0, 
  PRIMARY KEY (`ID`)
) ENGINE=myisam DEFAULT CHARSET=utf8;

#
# Dumping data for table 'tbl_106'
#

INSERT INTO `tbl_106` (`ID`, `VOL`, `REC`, `PAG`, `INDX`, `FOTO`, `FOTOLINK`, `ANNO`, `DATAIMMAGINE`, `TIPO`, `CHIESA`, `DA`, `A`) VALUES (413, 106, NULL, 1, NULL, 5417, 'cataldo106_001_5417#C:\\d\\access\\erice casa sales 2019/vol 106/cataldo106_001_5417.PAG 01.jpg#', 1675, '2019-08-24 00:00:00', 'Matrimoni', 'S.Cataldo', 1675, 1686);

unzip mydb.odb database/script

P.S. (just tested):
Tools>SQL…
script /tmp/test/mydb.sql [Execute] dumps the script file into the output box of the SQL dialog.
script /tmp/test/mydb.sql [Execute]
dumps the entire script including all the INSERT commands.

1 Like

Hello,

There is no facility in Base to create this. Base, using defaults, are embedded databases and copying the Base file is essentially a backup. If using an external database that database will typically provide a utility to create a backup or sql file (usually a choice you can make).

Now your question does not state the to/from databases. Previous questions refer to Firebird. With Base and Firebird embedded, the database is in the .odb and can be extracted with most archive managers. Firebird has a utility gbak which is a backup and restore utility. This may be of help.

Thanks for your reply. I had a look at gbak but could not generate what I needed.
Other options I looked at included scripts using “Create Text Table; Set Table; Insert Into” to generate a .csv file containing the database tables (suggested by another post) but these do not seem to be available with Firebird.

In the end I did manage to generate exactly what was required (i.e. a dump.sql file with all the CREATE TABLE and INSERT INTO TABLE necessary to import all the tables) by using a commercial product called RazorSQL. This worked perfectly and in a few seconds I had the .sql dump.

2 Likes

I spent a while also looking into the HSQLDB utility hsqldb_transfer, but couldn’t get it working right and the fading Web discussions suggest they’re not maintained.

RazorSQL seemed promising but did not “see” anything when connected to the .odb file created by Base. Probably I set up the connections wrong.

At first note the above mentioned usage is on Firebird not HSQLDB, but according to the docs it also handles Hsqldb.
.
The problem is: The database is “hidden” in a compressed zip file, so you need to unpack the database first. Maybe check the script to create a split-database by @Villeroy or start with this link to stackoverflow: https://stackoverflow.com/questions/18704570/how-can-i-read-in-java-an-hsql-data-base-built-using-libreoffice

Maybe it would be worse, if it were maintained: The embedded HSQLDB we see in .odb is version 1.8
IMHO current versions dropped reasing support for 1.8
https://hsqldb.org/doc/2.0/util-guide/transfer-tool-chapt.html