Opened 19 years ago

Closed 19 years ago

Last modified 18 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 Holovaty
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: no UI/UX: no

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 19 years ago.
patch

Download all attachments as: .zip

Change History (4)

by pb, 19 years ago

Attachment: dbclient.patch added

patch

comment:1 by Adrian Holovaty, 19 years ago

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 by anonymous, 19 years ago

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 by Adrian Holovaty, 19 years ago

Resolution: fixed
Status: newclosed

(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