]> git.jsancho.org Git - datasette-connectors.git/commitdiff
Improve table name extraction
authorJavier Sancho <jsf@jsancho.org>
Tue, 13 Oct 2020 09:42:30 +0000 (11:42 +0200)
committerJavier Sancho <jsf@jsancho.org>
Tue, 13 Oct 2020 09:42:30 +0000 (11:42 +0200)
datasette_connectors/cursor.py

index 166c84eb9e5f7a7c72e83166149ff89a2707df91..f3898cc23f4d97eca9eba0e12a9e7b1ea95fe240 100644 (file)
@@ -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)