How to prepare a statement from the CLI interpreter?
CLI was not designed for such. For this you must use an SQLite API on an available programming language.
You may also write a batch/shell file to handle CLI call.
E.g., in Windows a file named User.bat
like following:
@SQLITE3.EXE some.db "SELECT * FROM Users WHERE username='%~1'"
May be called like this:
User "jeffatwood"
will perform desired result.
EDIT:
About prepared/compiled statements: with those you can bind parameters, fetch queries row by row and repeat same command in a faster manner.
sqlite3 CLI tool wouldn't take any advantage on those:
- all parameters must be typed in SQL statement, making binding useless;
- all query rows are returned at once, no need to fetch row by row;
- repeated commands must be retyped - small speed improvement would result in using precompiled statements.