Ever wanted to go directly from an sql to xml files. I do 🙂 Here is a little tool I built a while back. It takes an xml (or any character structure) and an sql and returns one file per row returned result.
For example:
sqltofile -t "%user%%timestamp% " -s "SELECT user, timestamp FROM user" -h mysqlite.db
Will output (one file per row):
row0:niklas1363615417 row1:miew1363615493 row2:emma1363615604 ...
The words surrounded with % – signs in the -t argument above gets substituted by the values in the columns with the same name (minus the % -sign ).
Options to use:
-t Is the template string that contains the substitution variables surrounded by % – signs
-s This is the sql to run agains the database (* can be used)
-h Is the filename of the sqlite3 database to run the query agains
-o Outputs the result to stdout (optional)
-b Writes all lines to one file called row0 (optional)
You can find the source and an brief explanation of sqltofile here
0 Comments.