def execute(self): """The main method that splits the arguments and starts the magic""" options = self.options # search exact match of connection connection, opts = find_connection(Source.connections(), options, lambda con, opts: con.matches(opts)) if connection is None: raise UnknownConnectionException( options.uri, map(lambda c: c.autocomplete(), Source.connections())) if opts.show not in ('values', 'columns') or opts.filter is None: raise Exception('Specify the complete URI to a table') try: connection.connect(opts.database) tables = connection.tables() if opts.table not in tables: raise UnknownTableException(opts.table, tables.keys()) table = tables[opts.table] items = create_items( connection, connection.rows(table, opts.filter, opts.limit, simplify=False), opts.include, opts.exclude, opts.substitutes) # remove duplicates return list(OrderedDict.fromkeys(items)) finally: connection.close()
def build(self, options): cons = Source.connections() # search exact match of connection connection, opts = find_connection( cons, options, lambda con, opts: (opts.show != 'connections' and con.matches(opts))) if connection is not None: return create(connection, opts) # print all connections return sorted([c for c in cons if c.filter_(options)], key=lambda c: c.title().lower())
def execute(self): """The main method that splits the arguments and starts the magic""" options = self.options # search exact match of connection connection, opts = find_connection( Source.connections(), options, lambda con, opts: (con.matches(opts) and opts.show in ['databases', 'tables', 'columns', 'values'])) if connection is None: raise UnknownConnectionException( options.uri, map(lambda c: c.autocomplete(), Source.connections())) return self.process(connection, opts)
def execute(self): """The main method that splits the arguments and starts the magic""" options = self.options # search exact match of connection connection, opts = find_connection(Source.connections(), options, lambda con, opts: con.matches(opts)) if connection is None: raise UnknownConnectionException( options.uri, map(lambda c: c.autocomplete(), Source.connections())) if opts.show not in ['tables', 'columns', 'values']: raise Exception('Specify the complete URI to a table') return to_dto(self.build(connection, opts))
def build(self, options): cons = Source.connections() # search exact match of connection connection, opts = find_connection( cons, options, lambda con, opts: ( opts.show != 'connections' and con.matches(opts))) if connection is not None: return create(connection, opts) # print all connections return sorted( [c for c in cons if c.filter_(options)], key=lambda c: c.title().lower())
def execute(self): """The main method that splits the arguments and starts the magic""" options = self.options # search exact match of connection connection, opts = find_connection( Source.connections(), options, lambda con, opts: ( con.matches(opts) and opts.show in ['databases', 'tables', 'columns', 'values'])) if connection is None: raise UnknownConnectionException( options.uri, map(lambda c: c.autocomplete(), Source.connections())) return self.process(connection, opts)
def execute(self): """The main method that splits the arguments and starts the magic""" options = self.options # search exact match of connection connection, opts = find_connection( Source.connections(), options, lambda con, opts: con.matches(opts)) if connection is None: raise UnknownConnectionException( options.uri, map(lambda c: c.autocomplete(), Source.connections())) if opts.show not in ['tables', 'columns', 'values']: raise Exception('Specify the complete URI to a table') return to_dto(self.build(connection, opts))
def execute(self): """The main method that splits the arguments and starts the magic""" options = self.options # search exact match of connection connection, opts = find_connection( Source.connections(), options, lambda con, opts: con.matches(opts)) if connection is None: raise UnknownConnectionException( options.uri, map(lambda c: c.autocomplete(), Source.connections())) if opts.show not in ('values', 'columns') or opts.filter is None: raise Exception('Specify the complete URI to a table') try: connection.connect(opts.database) tables = connection.tables() if opts.table not in tables: raise UnknownTableException(opts.table, tables.keys()) table = tables[opts.table] items = create_items( connection, connection.rows( table, opts.filter, opts.limit, simplify=False), opts.include, opts.exclude, opts.substitutes) # remove duplicates return list(OrderedDict.fromkeys(items)) finally: connection.close()