Menu

Database_to_Document

Larry Jordan

Database to Document

If you have a database that receives periodic updates and you need to generate a report at scheduled intervals from the database. Here are the steps required to do this:

  1. Run an SQL query to get the data in csv format.
  2. Run csv2odf to convert to a document file.

This can be accomplished with a command like this in Linux:

cat query.sql | mysql -u Username -p | csv2odf template.ods > output.ods

The cat command pipes an SQL query to mysql. Mysql outputs csv data to csv2odf. Csv2odf outputs a nicely formatted ods spreadsheet.

A few options need to be added to the SQL query so that it will produce csv data:

SELECT field1, field2, field3
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM table;

Related

Wiki: Main_Page

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.