1 from .connection import Connection
10 for entry_point in pkg_resources.iter_entry_points('datasette.connectors'):
11 db_connectors[entry_point.name] = entry_point.load()
14 def add_connector(name, connector):
15 db_connectors[name] = connector
17 class DatabaseNotSupported(Exception):
22 for connector in db_connectors.values():
24 return connector.connect(path)
28 raise ConnectorList.DatabaseNotSupported
33 connection_class = Connection
36 def connect(cls, path):
37 return cls.connection_class(path, cls)
39 def __init__(self, conn):
42 def table_names(self):
44 Return a list of table names
46 raise NotImplementedError
48 def hidden_table_names(self):
49 raise NotImplementedError
51 def detect_spatialite(self):
53 Return boolean indicating if geometry_columns exists
55 raise NotImplementedError
59 Return a list of view names
61 raise NotImplementedError
63 def table_count(self, table_name):
65 Return an integer with the rows count of the table
67 raise NotImplementedError
69 def table_info(self, table_name):
71 Return a list of dictionaries with columns description, with format:
81 raise NotImplementedError
83 def detect_fts(self, table_name):
85 Return boolean indicating if table has a corresponding FTS virtual table
87 raise NotImplementedError
89 def foreign_keys(self, table_name):
91 Return a list of dictionaries with foreign keys description
92 id, seq, table_name, from_, to_, on_update, on_delete, match
94 raise NotImplementedError
96 def table_exists(self, table_name):
98 Return boolean indicating if table exists in the database
100 raise NotImplementedError
102 def table_definition(self, table_type, table_name):
104 Return string with a 'CREATE TABLE' sql definition
106 raise NotImplementedError
108 def indices_definition(self, table_name):
110 Return a list of strings with 'CREATE INDEX' sql definitions
112 raise NotImplementedError
119 custom_time_limit=None,
123 raise NotImplementedError