On Mon, May 28, 2012 at 5:09 AM, Vanessa Gomes <vane.gomesl@gmail.com> wrote:
> Hello, guys.
>
> Does anyone know where I can find the name / version of the database? For
> example, if I'm using PostegreSQL, want it returned something like "8.4.11
> PostgreSQL, psycopg2 2.4.4."
Hi Vanessa,
Django doesn't currently have any API for accessing that sort of
detail. You'd have to get a handle on the native DB cursor and ask the
DB directly. However, this won't be cross-database compatible -- every
database will have a different way of retrieving the version.
The closest Django can get you is to tell you the identifier for the
backend -- that will tell you that you're on Postgres vs MySQL, but
won't tell you versions.
from django.db import connections
print connections['default'].vendor
will output the database vendor string.
You're not the first person to ask for this feature-- there was a
ticket opened just recently for this exact idea:
https://code.djangoproject.com/ticket/18332
If you're enthused about the idea, this should be a fairly easy
contribution your could make.
Yours
Russ Magee %-)
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment