class Client(object): def __init__(self, host="localhost", port=6379, verbose=False): self.engine = Engine(host=host, port=port, verbose=verbose) self.lexer = SqlLexer().build() self.parser = SqlParser().build() def query(self, sql): ast = self.parser.parse(sql, lexer=self.lexer) if ast: result = self.engine.execute(ast) return result
def __init__(self, host="localhost", port=6379, verbose=False): self.engine = Engine(host=host, port=port, verbose=verbose) self.lexer = SqlLexer().build() self.parser = SqlParser().build()
def _process(self, sql, parsed_sql, select_clause, from_clause): p = SqlParser() results = p.parse(sql) self.assertEqual(str(results), str(parsed_sql)) self.assertEqual(str(results.select_clause), str(select_clause)) self.assertEqual(list(results.from_clause), from_clause)