LiteCLI - SQLite Client with Autocomplete
Written by Nikos Vaggalis   
Tuesday, 22 January 2019

LiteCLI is a new open source command line client with many good features. Built in Python it is hosted on GitHub.

There are quite a few SQLite GUI clients, such as DB Browser and Sqliteman, but not that many command line/terminal ones.
Despite being command line, the new offering, LiteCLI, is feature rich, including:

  • auto-completion when writing commands and SQL queries
  • auto-suggestion of tables having read the database schema
  • syntax highlighting 
  • saving and re-running favorite queries
  • table output in various formats
  • key bindings for emacs or vi
  • separate configuration file for persistence.

It all makes for a really smooth experience.

Installing it is just as easy. This is the way I'd suggest if you're on Windows:

Open a powershell session as admin and run:

>Set-ExecutionPolicy Bypass -Scope Process -Force;
         iex ((New-Object System.Net.WebClient).DownloadString(
             'https://chocolatey.org/install.ps1'))
 

Then:

>choco install python 

For a better terminal experience than the default cmd.exe, install Hyper which is based on Electron:

>choco install hyper

Open hyper and run:

>pip install -U litecli 

To take it for a test run, let's copy the places.sqlite database, where Firefox keeps the user's bookmarks, history etc to a test folder and run:

>litecli places.sqlite

Now inside the client, we can check the schema and work with the tables, say "moz_places", which can even be chosen from the list of the auto suggestions: 

litecli-autosuggestion

However, because the output of the row exceeds the width of the terminal, it doesn't look that good:


Thankfully LiteCLI has a very nice feature in going vertical :

 

Auto-suggestion aside, there's also Auto-completion:

And if there's a query that you frequently run, you can even save it as favorite and re-run it by just calling it by its nickname:

Another advantage of LiteCLI is that it's also fully customizable. For example you can change the syntax_style of the key bindings:

# Keybindings: Possible values: emacs, vi.
# Emacs mode: Ctrl-A is home, Ctrl-E is end.
 # All emacs keybindings are available in the REPL.

# When Vi mode is enabled you can use modal
 # editing features offered by Vi in the REPL.

key_bindings = emacs 

the table format output as seen when running SQL queries:

# Table format. Possible values: ascii, double, github,
# psql, plain, simple, grid, fancy_grid, pipe, orgtbl,
 # rst, mediawiki, html,# latex, latex_booktabs,
 # textile, moinmoin, jira, vertical, tsv, csv.

# Recommended: ascii
table_format = ascii

and much more.

I had been on the lookout for a good cli alternative like this for quickly running queries on databases stored inside Android emulators. 

It would had certainly come handy at the time I was doing my Android developer Nanodegree Capstone project. I could have  accessed my custom SQLite database simply as:

adb pull data/data/nvglabs.android.com.smartdeviceseeker
       /databases/smadeseek.db & litecli smadeseek.db

 

 

Better late than never!

More Information

LiteCli

Related Articles

Insider's Guide to Udacity Android Developer Nanodegree Part 7 - Full Stack Android

 

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

 

Banner


Deno Improves JSR Support
08/04/2024

Deno has been updated to improve JSR support, and to build on the Temporal API introduced in version 1.4.  Deno is the JavaScript and TypeScript runtime from the creator of Node.js.



GitLab Releases Duo Chat
22/04/2024

GitLab has announced that Duo Chat is now generally available in GitLab 16.11, offering a range of AI features in a single natural language chat experience.


More News

 

raspberry pi books

 

Comments




or email your comment to: comments@i-programmer.info

Last Updated ( Tuesday, 22 January 2019 )