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


The When and How Of Learning To Code
10/04/2019

The results of the 2019 Stack Overflow Developer Survey are out and, as usual, provide lots of useful insights into the global developer landscape. Here we look at when devs stated coding and the [ ... ]



Babel Adds Smart Pipelines
01/04/2019

Babel has been updated with support for smart pipelines and private instant accessors. The JavaScript compiler takes JavaScript ECMAScript 2015+ code and converts it into a backwards compatible versio [ ... ]


More News

 

Python

 



 

Comments




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

Last Updated ( Tuesday, 22 January 2019 )