#35094: Add pure Python `dbshell` fallback
-------------------------------------+-------------------------------------
               Reporter:  Jake       |          Owner:  nobody
  Howard                             |
                   Type:  New        |         Status:  new
  feature                            |
              Component:  Database   |        Version:  5.0
  layer (models, ORM)                |       Keywords:  sqlite dbshell in-
               Severity:  Normal     |  memory
           Triage Stage:             |      Has patch:  1
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 `dbshell` attempts to shell out to the client tooling for the relevant
 database engine (`sqlite3`, `psql` etc) for `dbshell`. If the tooling
 isn't installed, it can't shell. However, for a more naive shell
 implementation, it would be simple to pipe commands through to
 `connection.cursor().execute` and get at least some of the benefit without
 needing to install the client command-line tooling.

 Whilst this wouldn't have the client-side magic (eg backslash commands in
 Postgres or `.` commands in sqlite), nor tab complete, it can still be a
 lot more useful than nothing. An implementation of this shipped in Python
 3.12 for SQLite
 (https://github.com/python/cpython/blob/main/Lib/sqlite3/__main__.py),
 which can easily be adapted and made generic for all database engines.

 Doing this has a side benefit of also giving support for a `dbshell` for
 in-memory SQLite connections, which are currently misleading through
 `dbshell`, as it doesn't reuse the same connection that Django does,
 meaning any database bootstrapping done during startup (best-practice
 aside) is lost. An in-process connection reuses the same connnection, and
 thus allows access to that in-memory database.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/35094>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018ce8fc80dd-21577af9-507c-4e4e-9f67-ce38af639a45-000000%40eu-central-1.amazonses.com.

Reply via email to