from .connectors import Connector
+from .connection import Connection
from .cursor import OperationalError
class Connection:
- def __init__(self, path, connector):
+ def __init__(self, path, connector_class):
self.path = path
- self.connector = connector
+ self.connector_class = connector_class
def execute(self, *args, **kwargs):
cursor = Cursor(self)
connector_type = None
connection_class = Connection
- def connect(self, path):
- return self.connection_class(path, self)
+ @classmethod
+ def connect(cls, path):
+ return cls.connection_class(path, cls)
+
+ def __init__(self, conn):
+ self.conn = conn
def table_names(self):
"""
def __init__(self, conn):
self.conn = conn
- self.connector = conn.connector
+ self.connector = conn.connector_class(conn)
self.rows = []
self.description = ()
from datasette_connectors import monkey; monkey.patch_datasette()
from datasette_connectors.connectors import ConnectorList
from .dummy import DummyConnector
-ConnectorList.add_connector('dummy', DummyConnector())
+ConnectorList.add_connector('dummy', DummyConnector)
from datasette.app import Datasette
from datasette.utils.testing import TestClient