Parcourir la source

Check that PostgreSQL is 9.4 or higher on initialization

Jeremy Stretch il y a 7 ans
Parent
commit
f27e1ba885
1 fichiers modifiés avec 12 ajouts et 0 suppressions
  1. 12 0
      netbox/netbox/__init__.py

+ 12 - 0
netbox/netbox/__init__.py

@@ -0,0 +1,12 @@
+from distutils.version import StrictVersion
+
+from django.db import connection
+
+
+# NetBox v2.2 and later requires PostgreSQL 9.4 or higher
+with connection.cursor() as cursor:
+    cursor.execute("SELECT VERSION()")
+    row = cursor.fetchone()
+    pg_version = row[0].split()[1]
+    if StrictVersion(pg_version) < StrictVersion('9.4.0'):
+        raise Exception("PostgreSQL 9.4.0 or higher is required. ({} found)".format(pg_version))