Closed NSP-0123456 closed 2 years ago
You don't need to write select inja('
. It's for internal usage.
Write in an editor
{% for row in query("select * from books") %} {{ row.author }} {% endfor %}
and then run the query
P.S. I reproduced the error :(
I found the error and fixed it.
After a line https://github.com/little-brother/sqlite-gui/blob/master/extensions/inja.cpp#L14 should add
if (args.size() <= 1)
return 0;
I updated files of the latest realease (but didn't change git sources).
The query
{% for row in query("select * from books") %} {{ row.author }} {% endfor %}
will be converted to
Brandon Sanderson Cristin Terrill Jill McCorkle Kate Atkinson ...
It's a not a valid query, so you will not get a result.
Use
{% for row in query("select * from books limit 3") %} select {{ quote(row.author) }}; {% endfor %}
There are 3 changes:
limit
because there are 33 authors but sqlite-gui allows only 32 results.quote
author to generate a valid query select '<author>'
.;
to separate queries.P.S. Thanks for the report!
Using the template, i prefer to use it like :
select '{% for row in query("select * from books") %}"{{ row.author }}" {% endfor %}'
It could be good to have an export option using Jinja template file to generate report without having to be captured as a resultset.
Hmm, the interesting idea. I didn't suppose that someone wants to use scripting like this. The direct call select inja('{%...
has quotes
and highlighting
disadvantages.
I should figure out how to implement it in the most natural way. Perhaps, run the inja
-template in the terminal to return a inja
-generated result is a solution e.g.
But it slighty unobvious.
Done. Wiki was updated.
I'm trying to use Jinja template with query latest version inja.
// ref SQLite database editor
GUI version: 1.7.3 Architecture: x86-64 SQLite version: 3.38.5 Encryption support: Yes Build date: May 21 2022
OS: 10.0.19044 x64