GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add an interactive shell for Sqlite3 · Issue #77617 · python/cpython

Add an interactive shell for Sqlite3 #77617

New issue
Copy link
New issue
Copy link
Closed
#95026
Closed
Add an interactive shell for Sqlite3#77617
#95026
Copy link
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-sqlite3triagedThe issue has been accepted as valid by a triager.The issue has been accepted as valid by a triager.type-featureA feature request or enhancementA feature request or enhancement

Description

@rhettinger
rhettinger
opened on May 7, 2018
Issue body actions
BPO 33436
Nosy @rhettinger, @bitdancer, @serhiy-storchaka, @erlend-aasland, @DiddiLeija
Files
  • sqlite3_repl.py: Minimal proof-of-concept
  • 0001-Add-proof-of-concept-REPL.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2018-05-07.01:47:00.123>
    labels = ['3.8', '3.9', '3.10', '3.11', 'type-feature', 'library']
    title = 'Add an interactive shell for Sqlite3'
    updated_at = <Date 2022-02-11.14:45:10.289>
    user = 'https://github.com/rhettinger'

    bugs.python.org fields:

    activity = <Date 2022-02-11.14:45:10.289>
    actor = 'DiddiLeija'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2018-05-07.01:47:00.123>
    creator = 'rhettinger'
    dependencies = []
    files = ['47573', '49199']
    hgrepos = []
    issue_num = 33436
    keywords = ['patch']
    message_count = 6.0
    messages = ['316248', '316257', '316261', '327252', '370180', '413072']
    nosy_count = 6.0
    nosy_names = ['rhettinger', 'r.david.murray', 'serhiy.storchaka', 'Big Stone', 'erlendaasland', 'DiddiLeija']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = None
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue33436'
    versions = ['Python 3.8', 'Python 3.9', 'Python 3.10', 'Python 3.11']

    Activity

    Next
    1. rhettinger commented on May 7, 2018

      @rhettinger
      rhettinger
      on May 7, 2018
      ContributorAuthor
      More actions

      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
      
    2. rhettinger
      added
      3.8 (EOL)end of lifeend of life
      stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
      type-featureA feature request or enhancementA feature request or enhancement
      on May 7, 2018
    3. bitdancer commented on May 7, 2018

      @bitdancer
      bitdancer
      on May 7, 2018
      Member
      More actions

      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.)

    4. serhiy-storchaka commented on May 7, 2018

      @serhiy-storchaka
      serhiy-storchaka
      on May 7, 2018
      Member
      More actions

      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).

    5. BigStone commented on Oct 6, 2018

      @BigStone
      BigStonemannequin
      on Oct 6, 2018
      Mannequin
      More actions

      as a graphical sqlite browser, you have sqlite_bro that may give you inspiration. It's about one single file.

    6. erlend-aasland commented on May 28, 2020

      @erlend-aasland
      erlend-aasland
      on May 28, 2020
      Contributor
      More actions

      I think this is a good idea. Proof-of-concept implementation added (invoke REPL with python -m sqlite3).

      Possible improvements:
      - Use sqlite3.complete_statement()
      - Support Python syntax as well. For example:
      >>> select * from t
      >>> res = _
      >>> print(res[0])
    7. DiddiLeija commented on Feb 11, 2022

      @DiddiLeija
      DiddiLeijamannequin
      on Feb 11, 2022
      Mannequin
      More actions

      Do we still want to do this? See https://discuss.python.org/t/titling-sqlite3-table-columns-with-number/13656/3.

    8. DiddiLeija
      added
      3.9 (EOL)end of lifeend of life
      3.10 (EOL)end of lifeend of life
      3.11only security fixesonly security fixes
      on Feb 11, 2022
    9. ezio-melotti
      transferred this issue fromon Apr 10, 2022
    10. erlend-aasland
      added
      topic-sqlite3
      on May 16, 2022
    11. erlend-aasland
      added this to sqlite3 issueson May 21, 2022
    12. 4 remaining items

    13. erlend-aasland
      removed
      3.9 (EOL)end of lifeend of life
      3.8 (EOL)end of lifeend of life
      on Jul 17, 2022
    14. erlend-aasland commented on Jul 17, 2022

      @erlend-aasland
      erlend-aasland
      on Jul 17, 2022
      Contributor
      More actions

      @rhettinger, @serhiy-storchaka, are you still +1 on this? I'm +1, because...

      • implementation is easy; low maintenance cost
      • I'm a fan of built-in tools like this (python -m calendar is one of my favourites)
      • there has been some interest in this feature (re. the linked Discourse topic)
    15. serhiy-storchaka commented on Jul 18, 2022

      @serhiy-storchaka
      serhiy-storchaka
      on Jul 18, 2022
      Member
      More actions

      I am +1 on this for the same reasons. Go ahead, it would be fun.

      Reacted by Erlend E. Aasland
    16. kumaraditya303 commented on Jul 18, 2022

      @kumaraditya303
      kumaraditya303
      on Jul 18, 2022
      Contributor
      More actions

      I am +1, this would make Windows sqlite users happy.

      Reacted by Erlend E. Aasland
    17. erlend-aasland commented on Jul 18, 2022

      @erlend-aasland
      erlend-aasland
      on Jul 18, 2022
      Contributor
      More actions

      I'll revive my patch.

    18. erlend-aasland commented on Jul 19, 2022

      @erlend-aasland
      erlend-aasland
      on Jul 19, 2022
      Contributor
      More actions

      I'll revive my patch.

      Rebased and cleaned up slightly. Draft PR up: #95026

      IMO, let's just provide a dead simple sqlite3 shell for now; if more features are needed, let's add those in separate issues.

    19. erlend-aasland
      moved this to In Progress in sqlite3 issueson Jul 19, 2022
    20. erlend-aasland
      added
      triagedThe issue has been accepted as valid by a triager.The issue has been accepted as valid by a triager.
      on Jul 25, 2022
    21. erlend-aasland commented on Jul 31, 2022

      @erlend-aasland
      erlend-aasland
      on Jul 31, 2022
      Contributor
      More actions

      Possible future enhancements:

      • provide switches for overriding row and text factories
      • add more SQLite CLI features:
        • -cmd COMMAND: run "COMMAND" before reading stdin
        • -deserialize: open the database using sqlite3_deserialize()
        • -bail: stop after hitting an error
        • -readonly: open the database read-only
        • .trace command: set trace callback to print
        • .progress command: adds a basic progress handler
        • .connection [close] [#]: Open or close an auxiliary database connection
    22. erlend-aasland
      closed this as completedin #95026on Aug 1, 2022
    23. Repository owner moved this from In Progress to Done in sqlite3 issueson Aug 1, 2022
    24. erlend-aasland
      added a commit that references this issue on Aug 1, 2022

      gh-77617: Add sqlite3 command-line interface (#95026)

      bc7c7cd
    25. erlend-aasland commented on Aug 1, 2022

      @erlend-aasland
      erlend-aasland
      on Aug 1, 2022
      Contributor
      More actions

      Thanks Raymond, for the pitch. Thanks Dong-hee, Kumar, and Serhiy for helpful reviews. This has now been implemented by #95026. Enhancement requests go as separate issues.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-sqlite3triagedThe issue has been accepted as valid by a triager.The issue has been accepted as valid by a triager.type-featureA feature request or enhancementA feature request or enhancement

      Projects

      • sqlite3 issues
        Status
        Done
        Show more project fields

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.