Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#1631 closed enhancement (fixed)

[patch] django-admin.py dbclient: execute psql/mysql/sqlite3 client using project's DB settings

Reported by: pb@… Owned by: adrian
Component: Database layer (models, ORM) Version: magic-removal
Severity: trivial Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

OK, so I'm just scratching my own itch with this patch but I'm hoping others find it useful. If it needs to be kicked to the mailing list for more discussion that's fine.

It adds a command, django-admin.py dbclient (or manage.py dbclient) that launches the appropriate command-line client (psql, mysql, sqlite3) using DATABASE_* settings from the active settings file.

Note: I have tested this only on MySQL and SQLite back-ends -- I don't have a running PostgreSQL install, though I am fairly sure the command structure is correct. Nonetheless, testing is of course appreciated.

Attachments (1)

dbclient.patch (4.3 KB) - added by pb 9 years ago.
patch

Download all attachments as: .zip

Change History (4)

Changed 9 years ago by pb

patch

comment:1 Changed 9 years ago by adrian

Oooh! This is very cool, Paul! The one obvious imperfection is that it assumes the command-line clients are on the system path, but I think that's not too horrible of a requirement to use this feature.

comment:2 Changed 9 years ago by anonymous

Yeah, that seemed like an acceptable blemish to me given the alternatives. Glad you like it!

A sensible improvement would be to check for existence of the binaries before trying to invoke them, for nicer errors if nothing else. In Unix I'd do this with "which" but don't know a Windows/portable solution.

comment:3 Changed 9 years ago by adrian

  • Resolution set to fixed
  • Status changed from new to closed

(In [2693]) magic-removal: Fixed #1631 -- Added 'django-admin.py dbshell' command, which runs the command-line client for your database engine with your connection settings. Thanks, Paul Bissex

Note: See TracTickets for help on using tickets.
Back to Top