1 import datasette_connectors as dc
4 class DummyConnector(dc.Connector):
5 connector_type = 'dummy'
8 return ['table1', 'table2']
10 def hidden_table_names(self):
13 def detect_spatialite(self):
19 def table_count(self, table_name):
22 def table_info(self, table_name):
41 def detect_fts(self, table_name):
44 def foreign_keys(self, table_name):
47 def table_exists(self, table_name):
48 return table_name in ['table1', 'table2']
50 def table_definition(self, table_type, table_name):
51 return 'CREATE TABLE ' + table_name + ' (c1, c2, c3)'
53 def indices_definition(self, table_name):
61 custom_time_limit=None,
69 if sql == 'select c1 from table1':
74 description = (('c1',),)
75 elif sql == 'select c1, c2, c3 from table2 limit 51':
77 {'c1': 100, 'c2': 120, 'c3': 130},
78 {'c1': 200, 'c2': 220, 'c3': 230},
80 description = (('c1',), ('c2',), ('c3',))
81 elif sql == "select * from (select c1, c2, c3 from table2 ) limit 0":
83 elif sql == "select c1, count(*) as n from ( select c1, c2, c3 from table2 ) where c1 is not null group by c1 limit 31":
88 description = (('c1',), ('n',))
89 elif sql == "select c2, count(*) as n from ( select c1, c2, c3 from table2 ) where c2 is not null group by c2 limit 31":
94 description = (('c2',), ('n',))
95 elif sql == "select c3, count(*) as n from ( select c1, c2, c3 from table2 ) where c3 is not null group by c3 limit 31":
100 description = (('c3',), ('n',))
101 elif sql == 'select date(c1) from ( select c1, c2, c3 from table2 ) where c1 glob "????-??-*" limit 100;':
103 elif sql == "select c1, c2, c3 from blah limit 51":
104 raise dc.OperationalError("no such table: blah")
106 raise Exception("Unexpected query:", sql)
108 return results, truncated, description