classification
Title: Add an interactive shell for Sqlite3
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 3.8
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Big Stone, r.david.murray, rhettinger, serhiy.storchaka
Priority: normal Keywords:

Created on 2018-05-07 01:47 by rhettinger, last changed 2018-10-06 17:20 by Big Stone.

Files
File name Uploaded Description Edit
sqlite3_repl.py rhettinger, 2018-05-07 01:46 Minimal proof-of-concept
Messages (4)
msg316248 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2018-05-07 01:46
To facilitate rapid experimentation with SQL queries, add a shell to run commands and display results.

Attached is minimal proof-of-concept modeled loosely on the Linux sqlite3 REPL.  Here's a sample session:

    SQLite version 2.6.0

     Enter "help" for usage hints

    sqlite> open Irises.db
    sqlite> select distinct species from irises
    ('Iris-setosa',)
    ('Iris-versicolor',)
    ('Iris-virginica',)
    sqlite> select species, avg(pet_len), avg(sep_len) from irises group by species
    ('Iris-setosa', 1.464, 5.005999999999999)
    ('Iris-versicolor', 4.26, 5.936)
    ('Iris-virginica', 5.552, 6.587999999999998)
    sqlite> select count(*) from irises
    (150,)
    sqlite> quit
msg316257 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2018-05-07 10:52
It's not immediately obvious what benefits this provides over the existing sqlite-native repl and the python repl. Can you expand a bit on the use case?  Also, I seem to remember that Catherine Devlin had at one point thought about expanding her sqlpython to be multi-db capable, and while it doesn't look like that has happened, maybe that would be an alternative worth investigating?  (I've never used it or looked at its code, so it may not be.)
msg316261 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-05-07 11:07
It could be added in Tools/scripts directory or as a part of the sqlite3 module.

> It's not immediately obvious what benefits this provides over the existing sqlite-native repl and the python repl.

The existing sqlite-native repl is not always installed when Python is installed (especially on Windows). It is handy that Python provides CLI to some modules, including zipfile and tarfile.

I would prefer CLI, but maybe both interfaces can be combined.

It would be nice to provide also a graphical Sqlite3 browser, which can be ran as a separate application and be integrated with IDLE (as turtledemo).
msg327252 - (view) Author: Big Stone (Big Stone) Date: 2018-10-06 17:20
as a graphical sqlite browser, you have sqlite_bro that may give you inspiration. It's about one single file.
History
Date User Action Args
2018-10-06 17:20:52Big Stonesetnosy: + Big Stone
messages: + msg327252
2018-05-07 11:07:36serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg316261
2018-05-07 10:52:21r.david.murraysetnosy: + r.david.murray
messages: + msg316257
2018-05-07 01:47:00rhettingercreate