- h5tables[table._v_pathname] = {
- 'name': table._v_pathname,
- 'columns': colnames,
- 'primary_keys': [],
- 'count': int(table.nrows),
- 'label_column': None,
- 'hidden': False,
- 'fts_table': None,
- 'foreign_keys': {'incoming': [], 'outgoing': []},
- }
-
- h5file.close()
- return h5tables, views, _connector_type
-
-def _parse_sql(sql, params):
- # Table name
- sql = re.sub('(?i)from \[(.*)]', 'from "\g<1>"', sql)
- # Params
- for param in params:
- sql = sql.replace(":" + param, param)
-
- try:
- parsed = parse(sql)
- except:
- # Propably it's a PyTables expression
- for token in ['group by', 'order by', 'limit', '']:
- res = re.search('(?i)where (.*)' + token, sql)
- if res:
- modified_sql = re.sub('(?i)where (.*)(' + token + ')', '\g<2>', sql)
- parsed = parse(modified_sql)
- parsed['where'] = res.group(1).strip()
- break
-
- # Always a list of fields
- if type(parsed['select']) is not list:
- parsed['select'] = [parsed['select']]
-
- return parsed
-
-_operators = {
- 'eq': '==',
- 'neq': '!=',
- 'gt': '>',
- 'gte': '>=',
- 'lt': '<',
- 'lte': '<=',
- 'and': '&',
- 'or': '|',
-}
-
-class Connection:
- def __init__(self, path):
- self.path = path
- self.h5file = tables.open_file(path)
-
- def execute(self, sql, params=None, truncate=False, page_size=None, max_returned_rows=None):
- if params is None:
- params = {}
- rows = []
+ return [
+ {
+ 'idx': idx,
+ 'name': colname,
+ 'primary_key': False,
+ }
+ for idx, colname in enumerate(colnames)
+ ]
+
+ def hidden_table_names(self):
+ return []
+
+ def detect_spatialite(self):
+ return False
+
+ def view_names(self):
+ return []
+
+ def detect_fts(self, table_name):
+ return False
+
+ def foreign_keys(self, table_name):
+ return []
+
+ def execute(
+ self,
+ sql,
+ params=None,
+ truncate=False,
+ custom_time_limit=None,
+ page_size=None,
+ log_sql_errors=True,
+ ):
+ results = []