def check_interruption(): """Checks if the user is requesting to cancel an operation in progress. Call this from time to time so that the actual cancel requests can be handled """ if grt.query_status(): raise grt.UserInterrupt()
def execute_script(connection, script, log): connection = get_connection(connection) ranges = grt.modules.MysqlSqlFacade.getSqlStatementRanges(script) for start, length in ranges: if grt.query_status(): raise grt.UserInterrupt() statement = script[start:start + length] try: grt.send_info("Execute statement", statement) grt.log_debug3("DbMySQLFE", "Execute %s\n" % statement) connection.execute(statement) except db_utils.QueryError, exc: if log: entry = grt.classes.GrtLogEntry() entry.owner = log entry.name = str(exc) entry.entryType = 2 log.entries.append(entry) grt.send_warning("%s" % exc) grt.log_error("DbMySQLFE", "Exception executing '%s': %s\n" % (statement, exc)) return False except Exception, exc: if log: entry = grt.classes.GrtLogEntry() entry.owner = log entry.name = "Exception: " + str(exc) entry.entryType = 2 log.entries.append(entry) grt.send_warning("Exception caught: %s" % exc) grt.log_error("DbMySQLFE", "Exception executing '%s': %s\n" % (statement, exc)) return False
def execute_script(connection, script, log): connection = get_connection(connection) ranges = grt.modules.MysqlSqlFacade.getSqlStatementRanges(script) for start, length in ranges: if grt.query_status(): raise grt.UserInterrupt() statement = script[start:start+length] try: grt.send_info("Execute statement", statement) grt.log_debug3("DbMySQLFE", "Execute %s\n" % statement) connection.execute(statement) except db_utils.QueryError, exc: if log: entry = grt.classes.GrtLogEntry() entry.owner = log entry.name = str(exc) entry.entryType = 2 log.entries.append(entry) grt.send_warning("%s" % exc) grt.log_error("DbMySQLFE", "Exception executing '%s': %s\n" % (statement, exc)) return False except Exception, exc: if log: entry = grt.classes.GrtLogEntry() entry.owner = log entry.name = "Exception: " + str(exc) entry.entryType = 2 log.entries.append(entry) grt.send_warning("Exception caught: %s" % exc) grt.log_error("DbMySQLFE", "Exception executing '%s': %s\n" % (statement, exc)) return False
def getSchemaNames(connection): """Returns a list of schemas for the given connection object.""" names = [] result = get_connection(connection).executeQuery("SHOW DATABASES") if grt.query_status(): raise grt.UserInterrupt() while result and result.nextRow(): names.append(result.stringByIndex(1)) return names
def getTableNames(connection, schema): """Returns a list of the tables in the given schema for the given connection object.""" names = [] result = get_connection(connection).executeQuery("SHOW TABLES FROM `%s`" % schema) if grt.query_status(): raise grt.UserInterrupt() while result and result.nextRow(): names.append(result.stringByIndex(1)) return names
def check_interruption(): if grt.query_status(): raise grt.UserInterrupt()
def check_interruption(cls): if grt.query_status(): raise grt.UserInterrupt()