RobG
RobG

Reputation: 193

SQLite console command history with arrow keys

I have to think this has been asked, but I didn't find it with a simple search. I do hear others mention this problem, so I know it's not just me. I'm using Linux Mint 20, use the terminal regularly and rely on the up and down arrow keys to access the command history. But when I open the sqlite3 console those up and down keys give me ^[[A ^[[B respectively. Is there a configuration option somewhere that will remedy that? Thanks very much in advance!

Upvotes: 2

Views: 920

Answers (2)

raddevus
raddevus

Reputation: 9077

Running Ubuntu 22.04.3 LTS here.

I just had this problem where all of a sudden my copy of sqlite3 ( version 3.39.4 2022-09-29 15:55:41) stopped allow the up arrow from accessing my previous commands.

Then I remembered seeing a file in my home directory that was something about sqlite.

Did a dir and found a file named ~/.sqlite_history

I opened it up using nano and discovered that there were a ton of inserts in the file.

Oh, yeah, I ran 80 inserts by pasting them into the sqlite3 command console. It must've saved all of those.
I went ahead and deleted those lines from the ~/.sqlite_history file and save the file from the nano editor.

I opened up sqlite3 on the database I was using and the up-arrow key now lists the commands that are shown in the ~/.sqlite_history file.

I tried a new SELECT statement and it is now in the list of previously used commands too.

So, the point here is that maybe your ~/.sqlite_history file is corrupted.

Upvotes: 0

tuping
tuping

Reputation: 21

You may use rlwrap.

Install:

sudo apt install rlwrap

Run problematic program:

rlwrap sqlite3 <your_database.db>

Long explanation: https://superuser.com/questions/561087/strange-keyboard-when-using-sqlite-shell-on-linux/

Upvotes: 2

Related Questions