Hello,
You can probably do something like this:
import sys from django.db import connection with connection.cursor() as cursor: cursor.execute("SELECT version()") result = cursor.fetchone()[0] sys.stdout.write(result + '\n')
This prints out something like "PostgreSQL 9.4.12 on x86_64-unknown-linux-gnu, compiled by gcc (Debian 4.9.2-10) 4.9.2, 64-bit".
The "SELECT version()" is a PostgreSQL-specific way of getting
the server version. The rest is Django's
way of executing raw SQL queries.
Regards,
Antonis
Antonis Christofides http://djangodeployment.com