2 from .connection import Connection
11 for entry_point in pkg_resources.iter_entry_points('datasette.connectors'):
12 db_connectors[entry_point.name] = entry_point.load()
15 def add_connector(name, connector):
16 db_connectors[name] = connector
18 class DatabaseNotSupported(Exception):
23 for connector in db_connectors.values():
25 return connector.connect(path)
29 raise ConnectorList.DatabaseNotSupported
34 connection_class = Connection
37 def connect(cls, path):
38 return cls.connection_class(path, cls)
40 def __init__(self, conn):
43 def table_names(self):
45 Return a list of table names
47 raise NotImplementedError
49 def hidden_table_names(self):
50 raise NotImplementedError
52 def detect_spatialite(self):
54 Return boolean indicating if geometry_columns exists
56 raise NotImplementedError
60 Return a list of view names
62 raise NotImplementedError
64 def table_count(self, table_name):
66 Return an integer with the rows count of the table
68 raise NotImplementedError
70 def table_info(self, table_name):
72 Return a list of dictionaries with columns description, with format:
82 raise NotImplementedError
84 def detect_fts(self, table_name):
86 Return boolean indicating if table has a corresponding FTS virtual table
88 raise NotImplementedError
90 def foreign_keys(self, table_name):
92 Return a list of dictionaries with foreign keys description
93 id, seq, table_name, from_, to_, on_update, on_delete, match
95 raise NotImplementedError
97 def table_exists(self, table_name):
99 Return boolean indicating if table exists in the database
101 raise NotImplementedError
103 def table_definition(self, table_type, table_name):
105 Return string with a 'CREATE TABLE' sql definition
107 raise NotImplementedError
109 def indices_definition(self, table_name):
111 Return a list of strings with 'CREATE INDEX' sql definitions
113 raise NotImplementedError
120 custom_time_limit=None,
124 raise NotImplementedError