[Django] #29501: Add support for ./manage.py dbshell -c SQL

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

[Django] #29501: Add support for ./manage.py dbshell -c SQL

Django
#29501: Add support for ./manage.py dbshell -c SQL
-------------------------------------+-------------------------------------
               Reporter:  Artem      |          Owner:  nobody
  Skoretskiy                         |
                   Type:  New        |         Status:  new
  feature                            |
              Component:  Core       |        Version:  2.0
  (Management commands)              |
               Severity:  Normal     |       Keywords:
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 At the moment you cannot run specific SQL directly with `dbshell`:

 {{{
 ./manage.py dbshell -c "select * from auth_group"
 }}}

 You have to use pipes, that are not always convenient:

 {{{
 echo "select * from auth_group" | ./manage.py dbshell
 }}}

 If we add `-c` argument, it would be in sync with `shell` command, where
 you could provide commands already.

--
Ticket URL: <https://code.djangoproject.com/ticket/29501>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/050.1904cba83a5463f09ecc1536b00d3e4a%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29501: Add support for ./manage.py dbshell -c SQL

Django
#29501: Add support for ./manage.py dbshell -c SQL
-------------------------------------+-------------------------------------
     Reporter:  Artem Skoretskiy     |                    Owner:  nobody
         Type:  New feature          |                   Status:  new
    Component:  Core (Management     |                  Version:  master
  commands)                          |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

 * version:  2.0 => master
 * stage:  Unreviewed => Accepted


Comment:

 This seems reasonable, at first glance at least. The trick will be to pass
 the command to each of the backend clients correctly, but there's no
 reason that's not possible right? Accepting on that basis. A PR is very
 welcome.

--
Ticket URL: <https://code.djangoproject.com/ticket/29501#comment:1>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.82861a70ef60c88cc267eab88fb9a023%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29501: Add support for ./manage.py dbshell -c SQL

Django
In reply to this post by Django
#29501: Add support for ./manage.py dbshell -c SQL
-------------------------------------+-------------------------------------
     Reporter:  Artem Skoretskiy     |                    Owner:  Zijian He
         Type:  New feature          |                   Status:  assigned
    Component:  Core (Management     |                  Version:  master
  commands)                          |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Zijian He):

 * owner:  nobody => Zijian He
 * cc: Zijian He (added)
 * status:  new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/29501#comment:2>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.aa1895a8d1a836fac68fffb6c2d45483%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29501: Add support for ./manage.py dbshell -c SQL

Django
In reply to this post by Django
#29501: Add support for ./manage.py dbshell -c SQL
-------------------------------------+-------------------------------------
     Reporter:  Artem Skoretskiy     |                    Owner:  cedric05
         Type:  New feature          |                   Status:  assigned
    Component:  Core (Management     |                  Version:  master
  commands)                          |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by cedric05):

 * owner:  Zijian He => cedric05


--
Ticket URL: <https://code.djangoproject.com/ticket/29501#comment:3>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.fcf15101b3ad5227d2fbc692f553165d%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29501: Add support for ./manage.py dbshell -c SQL

Django
In reply to this post by Django
#29501: Add support for ./manage.py dbshell -c SQL
-------------------------------------+-------------------------------------
     Reporter:  Artem Skoretskiy     |                    Owner:  (none)
         Type:  New feature          |                   Status:  new
    Component:  Core (Management     |                  Version:  master
  commands)                          |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Shiva Prasanth):

 * status:  assigned => new
 * owner:  Shiva Prasanth => (none)


--
Ticket URL: <https://code.djangoproject.com/ticket/29501#comment:4>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.883d35edbc54e1a555fe392e148ee811%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29501: Add support for ./manage.py dbshell -c SQL

Django
In reply to this post by Django
#29501: Add support for ./manage.py dbshell -c SQL
-------------------------------------+-------------------------------------
     Reporter:  Artem Skoretskiy     |                    Owner:  (none)
         Type:  New feature          |                   Status:  new
    Component:  Core (Management     |                  Version:  master
  commands)                          |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Artem Skoretskiy):

 It should be easy to implement since we don’t need to use database-
 specific backend

 Something like that:

 {{{
 from django.db import connection

 if command:
     cursor = connection.cursor()
     cursor.execute(command)
     # show `cursor.fetchall()` result
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29501#comment:5>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.0730b4d6350bbe01d10f7328e84bc90e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29501: Add support for ./manage.py dbshell -c SQL

Django
In reply to this post by Django
#29501: Add support for ./manage.py dbshell -c SQL
-------------------------------------+-------------------------------------
     Reporter:  Artem Skoretskiy     |                    Owner:  (none)
         Type:  New feature          |                   Status:  new
    Component:  Core (Management     |                  Version:  master
  commands)                          |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Volodymyr Dmytriiev):

 any progress on this one? Is the previously suggested approach good
 enough? If so, I'd love to give a try?

--
Ticket URL: <https://code.djangoproject.com/ticket/29501#comment:6>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.aa4448d62b114d160a972a859cdbc949%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29501: Add support for ./manage.py dbshell -c SQL

Django
In reply to this post by Django
#29501: Add support for ./manage.py dbshell -c SQL
-------------------------------------+-------------------------------------
     Reporter:  Artem Skoretskiy     |                    Owner:  (none)
         Type:  New feature          |                   Status:  new
    Component:  Core (Management     |                  Version:  master
  commands)                          |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Artem Skoretskiy):

 No progress AKAIK.

 Maybe it would be easier to call database-specific CLI tool with right
 parameters than run cursor.

 Pros:
 * No need to care about printing results (user could execute SELECT)
 * Could run commands that are unique for the CLI (e.g. \dt to show tables
 in psql)

 Cons:
 * Each backend would need its own command to run (but we already have
 dbshell, so we know name of binary; just need a parameter to execute a
 query).
 * Each backend would show results in its own format, so you cannot e. g.
 save result as cab file)

 Another completely different approach would be to pass all command line
 arguments provided to dbshell, e.g. after “—“ divider to database CLI app.
 For example:
 {{{
 ./manage.py dbshell — -c “select * from auth_user”
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29501#comment:7>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.dd339b1cd2431d4783ce529542780085%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29501: Add support for ./manage.py dbshell -c SQL

Django
In reply to this post by Django
#29501: Add support for ./manage.py dbshell -c SQL
-------------------------------------+-------------------------------------
     Reporter:  Artem Skoretskiy     |                    Owner:  (none)
         Type:  New feature          |                   Status:  new
    Component:  Core (Management     |                  Version:  master
  commands)                          |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Adam (Chainz) Johnson):

 I don't think opening a cursor is the right way. My mental model of
 dbshell is that it always passes through to the underlying tool, which can
 have subtle implications on even what SQL/commands are accepted.

 I am actually most in favour of passing all arguments through after a `--`
 divider as that is the most flexible.

--
Ticket URL: <https://code.djangoproject.com/ticket/29501#comment:8>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.721347f53b53502599ed825f0e1a34c1%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29501: Add support for ./manage.py dbshell -c SQL

Django
In reply to this post by Django
#29501: Add support for ./manage.py dbshell -c SQL
-------------------------------------+-------------------------------------
     Reporter:  Artem Skoretskiy     |                    Owner:
                                     |  introquest
         Type:  New feature          |                   Status:  assigned
    Component:  Core (Management     |                  Version:  master
  commands)                          |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by introquest):

 * status:  new => assigned
 * owner:  (none) => introquest


--
Ticket URL: <https://code.djangoproject.com/ticket/29501#comment:9>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.8f12a54cf78796061c7545f76871ae63%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29501: Add support for ./manage.py dbshell -c SQL

Django
In reply to this post by Django
#29501: Add support for ./manage.py dbshell -c SQL
-------------------------------------+-------------------------------------
     Reporter:  Artem Skoretskiy     |                    Owner:
                                     |  introquest
         Type:  New feature          |                   Status:  assigned
    Component:  Core (Management     |                  Version:  master
  commands)                          |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Ready for
                                     |  checkin
    Has patch:  1                    |      Needs documentation:  1
  Needs tests:  1                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by introquest):

 * needs_docs:  0 => 1
 * has_patch:  0 => 1
 * needs_tests:  0 => 1
 * stage:  Accepted => Ready for checkin


Comment:

 https://github.com/django/django/pull/10186

--
Ticket URL: <https://code.djangoproject.com/ticket/29501#comment:10>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.922c90b3f3179af2c44506f7b633e93c%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29501: Add support for ./manage.py dbshell -c SQL

Django
In reply to this post by Django
#29501: Add support for ./manage.py dbshell -c SQL
-------------------------------------+-------------------------------------
     Reporter:  Artem Skoretskiy     |                    Owner:
                                     |  introquest
         Type:  New feature          |                   Status:  assigned
    Component:  Core (Management     |                  Version:  master
  commands)                          |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  1
  Needs tests:  1                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

 * stage:  Ready for checkin => Accepted


Comment:

 "Ready for checkin" is set by a patch reviewer. And the patch isn't ready
 for review without tests and documentation.

--
Ticket URL: <https://code.djangoproject.com/ticket/29501#comment:11>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.b59974260b1a0c95ade9267b886f9228%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29501: Add support for ./manage.py dbshell -c SQL

Django
In reply to this post by Django
#29501: Add support for ./manage.py dbshell -c SQL
-------------------------------------+-------------------------------------
     Reporter:  Artem Skoretskiy     |                    Owner:
                                     |  introquest
         Type:  New feature          |                   Status:  assigned
    Component:  Core (Management     |                  Version:  master
  commands)                          |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  1
  Needs tests:  1                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by David Vaz):

 So the PR is closed due to missing Tests and Documentation. Does anybody
 care that I take this?
 I could make a PR based on the original one and add tests and docs

--
Ticket URL: <https://code.djangoproject.com/ticket/29501#comment:12>
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.1106398fd88aca379f54243f6ebd22b9%40djangoproject.com.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29501: Add support for ./manage.py dbshell -c SQL

Django
In reply to this post by Django
#29501: Add support for ./manage.py dbshell -c SQL
-------------------------------------+-------------------------------------
     Reporter:  Artem Skoretskiy     |                    Owner:
                                     |  introquest
         Type:  New feature          |                   Status:  assigned
    Component:  Core (Management     |                  Version:  master
  commands)                          |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  1
  Needs tests:  1                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Claude Paroz):

 Absolutely, feel free to work on issues obviously stalled. Just credit
 original patch writers if appropriate.

--
Ticket URL: <https://code.djangoproject.com/ticket/29501#comment:13>
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.61f19be1c75b1b55775b170e1ee3ccc5%40djangoproject.com.