SQLite Forum

SQLite3.exe Command shell: Iterate over table of csv files?
Login
> If programmability is not available in the command shell...

...then you're using a terribly weak excuse for a command shell. :)

Dr. Bourne taught the world that programmable command shells was a good idea in *1977.* His shell for UNIX V7 had logical expressions and loops, which didn't arrive in `cmd.exe` until decades later. If you take the original Unix shell spirit, we also had the ability to do arithmetic on variables, allowing us to clean up all that manual "`([Gt 24 to 25 Weeks SUM 1]*25)+`" stuff in your Lua code via `expr` and `bc`.

I believe you can do that today via your original `cmd.exe` method by using its [`FOR` feature](https://ss64.com/nt/for.html), but I wouldn't bother. Instead, I recommend that you continue down your new path: use a better-designed programming language from the start rather than try to arm-twist `cmd.exe` to suit.

> This Lua script generates a .sqlite file

Why ever for? [Call SQLite directly from Lua](http://lua.sqlite.org/) instead. It'll not only save you the temporary output SQL file, it'll run faster.

If you don't like that wrapper, I count [seven others](https://luarocks.org/labels/database?non_root=on). (Do note that `lsqlite3` is far and away the most popular among them, though.)

And again, you really should generate that "Gt...Weeks SUM" stuff rather than write it manually.