Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prepare a statement from the CLI interpreter?

How does one prepare a statement from the SQLite CLI? I have found the page Compiling An SQL Statement but it is geared more towards the ODBC interface, not the CLI interpreter. I'm hopinpg for something akin to the following:

sqlite> pq = prepare(SELECT * FROM Users WHERE username=?)
sqlite> run(pq, 'jeffatwood')
0 | jeffatwood | hunter2 | admin
sqlite> 

Does the SQLite CLI have any such functionality? Note that I am not referring to the Bash CLI but rather SQLite's CLI interpreter or the excellent LiteCLI alternative.

like image 757
dotancohen Avatar asked Nov 19 '13 07:11

dotancohen


1 Answers

Perhaps SQL Parameters using named parameters would do the trick

sqlite> .param set :user 'jeffatwood'
sqlite> select * from Users where username = :user

should return the desired row.

like image 79
DinoCoderSaurus Avatar answered Nov 23 '22 12:11

DinoCoderSaurus