SQLite Forum

CLI shell history
Login
> Otherwise .sqliite_history does get deleted, but reappears.

Of course: the history is read into RAM on program initialization, then written from RAM on exit. Removing the history file while the program runs just means that *another* instance started in parallel will start with an empty history. Exiting the first instance rewrites the history from RAM.

> Is there a way just to 'clear' the current history session without deleting the file?

After the "cookie" line (`_HiStOrY_V2_`) each line is a typed line with whitespace and other special characters replaced with octal escape sequences. See `history_save()` in [`history.c`][1] from [Apple's version of libedit][2].

Other versions of libedit ([example][3]) do without the cookie line entirely, and they don't do any special character escaping, that I can see.

Then there's GNU readline, which is yet another ball of wax.

They're all lumped together because they implement the same API, and the SQLite shell can be built against any of them. The stock macOS version of `sqlite3` just happens to be built against Apple's fork of `libedit`, so that's the history file flavor you get with that build of the SQLite shell.

**EDIT:** All of this means that given the file format details, you can open that file in a text editor and delete the bits of history you don't want to reappear in a later call to `sqlite3`, so long as your saved history file continues to follow the rules for the particular line editor library that wrote the file.

[1]: https://opensource.apple.com/source/libedit/libedit-55/src/history.c.auto.html
[2]: https://opensource.apple.com/source/libedit/libedit-55/
[3]: https://github.com/troglobit/editline