]> git.jsancho.org Git - datasette-connectors.git/blobdiff - datasette_connectors/cursor.py
datasette==0.51.1
[datasette-connectors.git] / datasette_connectors / cursor.py
index f3898cc23f4d97eca9eba0e12a9e7b1ea95fe240..02585a367e1957d8f55aa1e4c634a6b25392bf9d 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\(\[?\"?([\d\w\/]*)\"?\]?\)', 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)
@@ -67,7 +67,8 @@ class Cursor:
             if self.connector.table_exists(params[0]):
                 results = [{'1': '1'}]
         elif sql == "select sql from sqlite_master where name = :n and type=:t":
-            results = [{'sql': self.connector.table_definition(params['t'], params['n'])}]
+            if self.connector.table_exists(params['n']):
+                results = [{'sql': self.connector.table_definition(params['t'], params['n'])}]
         elif sql == "select sql from sqlite_master where tbl_name = :n and type='index' and sql is not null":
             results = [{'sql': sql} for sql in self.connector.indices_definition(params['n'])]
         else: