server/sqlutils.py
changeset 10607 6519ae8cca0c
parent 10589 7c23b7de2b8d
child 10612 84468b90e9c1
equal deleted inserted replaced
10606:718e78ef6699 10607:6519ae8cca0c
    23 import sys
    23 import sys
    24 import os
    24 import os
    25 import re
    25 import re
    26 import subprocess
    26 import subprocess
    27 from os.path import abspath
    27 from os.path import abspath
    28 from itertools import ifilter
       
    29 from logging import getLogger
    28 from logging import getLogger
       
    29 
       
    30 from six.moves import filter
    30 
    31 
    31 from logilab import database as db, common as lgc
    32 from logilab import database as db, common as lgc
    32 from logilab.common.shellutils import ProgressBar, DummyProgressBar
    33 from logilab.common.shellutils import ProgressBar, DummyProgressBar
    33 from logilab.common.deprecation import deprecated
    34 from logilab.common.deprecation import deprecated
    34 from logilab.common.logging_ext import set_log_methods
    35 from logilab.common.logging_ext import set_log_methods
   176 
   177 
   177     cmds = [dbhelper.sql_drop_sequence('entities_id_seq')]
   178     cmds = [dbhelper.sql_drop_sequence('entities_id_seq')]
   178     # for mssql, we need to drop views before tables
   179     # for mssql, we need to drop views before tables
   179     if hasattr(dbhelper, 'list_views'):
   180     if hasattr(dbhelper, 'list_views'):
   180         cmds += ['DROP VIEW %s;' % name
   181         cmds += ['DROP VIEW %s;' % name
   181                  for name in ifilter(_SQL_DROP_ALL_USER_TABLES_FILTER_FUNCTION, dbhelper.list_views(sqlcursor))]
   182                  for name in filter(_SQL_DROP_ALL_USER_TABLES_FILTER_FUNCTION, dbhelper.list_views(sqlcursor))]
   182     cmds += ['DROP TABLE %s;' % name
   183     cmds += ['DROP TABLE %s;' % name
   183              for name in ifilter(_SQL_DROP_ALL_USER_TABLES_FILTER_FUNCTION, dbhelper.list_tables(sqlcursor))]
   184              for name in filter(_SQL_DROP_ALL_USER_TABLES_FILTER_FUNCTION, dbhelper.list_tables(sqlcursor))]
   184     return '\n'.join(cmds)
   185     return '\n'.join(cmds)
   185 
   186 
   186 
   187 
   187 class ConnectionWrapper(object):
   188 class ConnectionWrapper(object):
   188     """handle connection to the system source, at some point associated to a
   189     """handle connection to the system source, at some point associated to a