Use django's API...

see #835
This commit is contained in:
Antoine Nguyen
2016-02-16 16:20:23 +01:00
parent 1b00e979c0
commit 87447e56f8
2 changed files with 3 additions and 18 deletions
-1
View File
@@ -8,7 +8,6 @@ from django.shortcuts import render
from django.template.loader import render_to_string
from django.utils.translation import ugettext as _
from modoboa.core.extensions import exts_pool
from modoboa.core.models import Log
from modoboa.core.utils import check_for_updates
from modoboa.lib import events, parameters
+3 -17
View File
@@ -7,23 +7,9 @@ from django.utils.translation import ugettext as _
from modoboa.lib.exceptions import InternalError
def db_table_exists(table, cursor=None):
"""Check if table exists
Taken from here:
https://gist.github.com/527113/307c2dec09ceeb647b8fa1d6d49591f3352cb034
"""
try:
if not cursor:
cursor = connection.cursor()
if not cursor:
raise Exception
table_names = connection.introspection.get_table_list(cursor)
except:
raise Exception("unable to determine if the table '%s' exists" % table)
else:
return table in table_names
def db_table_exists(table):
"""Check if table exists."""
return table in connection.introspection.table_names()
def db_type(cname="default"):