mirror of
https://github.com/ansible/awx.git
synced 2026-05-13 04:17:36 -02:30
add mgmt cmd to check db connection
This commit is contained in:
17
awx/main/management/commands/check_db.py
Normal file
17
awx/main/management/commands/check_db.py
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
# Copyright (c) 2015 Ansible, Inc.
|
||||||
|
# All Rights Reserved
|
||||||
|
|
||||||
|
from django.core.management.base import BaseCommand
|
||||||
|
from django.db import connection
|
||||||
|
|
||||||
|
|
||||||
|
class Command(BaseCommand):
|
||||||
|
"""Checks connection to the database, and prints out connection info if not connected"""
|
||||||
|
|
||||||
|
def handle(self, *args, **options):
|
||||||
|
|
||||||
|
with connection.cursor() as cursor:
|
||||||
|
cursor.execute("SELECT version()")
|
||||||
|
version = str(cursor.fetchone()[0])
|
||||||
|
|
||||||
|
return "Database Version: {}".format(version)
|
||||||
Reference in New Issue
Block a user