1 from datasette_connectors.row import Row
4 _connector_type = 'dummy'
10 for table in ['table1', 'table2']:
13 'columns': ['c1', 'c2', 'c3'],
19 'foreign_keys': {'incoming': [], 'outgoing': []},
22 return tables, views, _connector_type
26 def __init__(self, path):
29 def execute(self, sql, params=None, truncate=False, page_size=None, max_returned_rows=None):
36 if sql == 'select c1 from table1':
41 description = (('c1',),)
42 elif sql == 'select rowid, * from table2 order by rowid limit 51':
44 Row({'rowid': 1, 'c1': 100, 'c2': 120, 'c3': 130}),
45 Row({'rowid': 2, 'c1': 200, 'c2': 220, 'c3': 230})
47 description = (('rowid',), ('c1',), ('c2',), ('c3',))
48 elif sql == 'select count(*) from table2':
49 rows = [Row({'count(*)': 2})]
50 description = (('count(*)',),)
51 elif sql == """select distinct rowid from table2
52 where rowid is not null
58 description = (('rowid',),)
59 elif sql == """select distinct c1 from table2
66 description = (('c1',),)
67 elif sql == """select distinct c2 from table2
74 description = (('c2',),)
75 elif sql == """select distinct c3 from table2
82 description = (('c3',),)
83 elif sql == 'select sql from sqlite_master where name = :n and type=:t':
84 if params['t'] != 'view':
85 rows = [Row({'sql': 'CREATE TABLE ' + params['n'] + ' (c1, c2, c3)'})]
86 description = (('sql',),)
88 raise Exception("Unexpected query: %s" % sql)
90 return rows, truncated, description