2

I need to script the insertion of records into a database. For this project (my first such), I'm using libreoffice Base with, for no particular reason, an HSQLDB back-end. Is there a cli interface that would let me do that?

  • HSQLDB comes with a command-line SQL tool, so why not use that and bypass LibreOffice Base entirely? – Jos Apr 12 '16 at 11:50
  • If you're using an embedded HSQLDB, you'll need to convert it into a split database before accessing it using CLI tools. – tohuwawohu Apr 12 '16 at 11:54
  • @Jos - is that the package hsqldb-utils? (I'm learning as I go. I think the only reason to use Base is to access and make use of the DB after I've got the data in there. It's all new, though!) – Diagon Apr 12 '16 at 12:08
  • @tohuwawohu - Ahhh, thanks, I think! Could you expand? :) – Diagon Apr 12 '16 at 12:08
  • The SQL tool is part of the package hsqldb-utils. The command to start it is hsqldb-sqltool. – Jos Apr 12 '16 at 12:45
2

The easiest way to manipulate a HSQLDB database by means of scripts would be to use the tool sqltool provided in the package. You can do things like:

hsqldb-sqltool urlid --SQL="SQL statement 1; SQL statement 2; ..."

(where urlid is a file containing connection details), or read a bunch of SQL statements from a file, like this:

hsqldb-sqltool urlid file1.sql

NB: As @tohuwawohu points out, the database needs to be set up as a server to access it this way, rather than as "embedded", which is the first thing LibreOffice Base offers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.