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):
29 'default_value': None,
37 'default_value': None,
45 'default_value': None,
50 def detect_fts(self, table_name):
53 def foreign_keys(self, table_name):
56 def table_exists(self, table_name):
57 return table_name in ['table1', 'table2']
59 def table_definition(self, table_type, table_name):
60 return 'CREATE TABLE ' + table_name + ' (c1, c2, c3)'
62 def indices_definition(self, table_name):
70 custom_time_limit=None,
78 if sql == 'select c1 from table1':
83 description = (('c1',),)
84 elif sql == 'select c1, c2, c3 from table2 limit 51':
86 {'c1': 100, 'c2': 120, 'c3': 130},
87 {'c1': 200, 'c2': 220, 'c3': 230},
89 description = (('c1',), ('c2',), ('c3',))
90 elif sql == "select * from (select c1, c2, c3 from table2 ) limit 0":
92 elif sql == "select c1, count(*) as n from ( select c1, c2, c3 from table2 ) where c1 is not null group by c1 limit 31":
97 description = (('c1',), ('n',))
98 elif sql == "select c2, count(*) as n from ( select c1, c2, c3 from table2 ) where c2 is not null group by c2 limit 31":
103 description = (('c2',), ('n',))
104 elif sql == "select c3, count(*) as n from ( select c1, c2, c3 from table2 ) where c3 is not null group by c3 limit 31":
109 description = (('c3',), ('n',))
110 elif sql == 'select date(c1) from ( select c1, c2, c3 from table2 ) where c1 glob "????-??-*" limit 100;':
112 elif sql == "select c1, c2, c3 from blah limit 51":
113 raise dc.OperationalError("no such table: blah")
115 raise Exception("Unexpected query:", sql)
117 return results, truncated, description