]> git.jsancho.org Git - datasette-connectors.git/blobdiff - datasette_connectors/cursor.py
Improve table name extraction
[datasette-connectors.git] / datasette_connectors / cursor.py
index 6facf548bd3460bef5c7393ced470b062093d9b6..f3898cc23f4d97eca9eba0e12a9e7b1ea95fe240 100644 (file)
@@ -14,7 +14,7 @@ class Cursor:
 
     def __init__(self, conn):
         self.conn = conn
-        self.connector = conn.connector
+        self.connector = conn.connector_class(conn)
         self.rows = []
         self.description = ()
 
@@ -54,7 +54,7 @@ class Cursor:
             match = re.search(r'select count\(\*\) from (.*)', sql)
             results = [{'count(*)': self.connector.table_count(match.group(1))}]
         elif sql.startswith("PRAGMA table_info("):
-            match = re.search(r'PRAGMA table_info\((.*)\)', sql)
+            match = re.search(r'PRAGMA table_info\(\[?\"?([\d\w\/]*)\"?\]?\)', sql)
             results = self.connector.table_info(match.group(1))
         elif sql.startswith("select name from sqlite_master where rootpage = 0 and ( sql like \'%VIRTUAL TABLE%USING FTS%content="):
             match = re.search(r'select name from sqlite_master where rootpage = 0 and \( sql like \'%VIRTUAL TABLE%USING FTS%content="(.*)"', sql)