prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Loading schema for Sqlite DB with "Order" column name fails
  ### Issue Summary
  
  I added a Sqlite Database which has an column with the name `Order`.
  When I try to create a query, the error `Schema refresh failed.` comes up.
  
  ### Steps to Reproduce
  
  1. Add an Sqlite Database which has a column with the name `Order`
  2. Try to create a query
  3. Get the error `Schema refresh failed.`
  
  
  ### Technical details:
  
  * Redash Version: cloned from master
  * Browser/OS: Brave Browser & Ubuntu 18.1
  * How did you install Redash: built from source
  
  
  </issue>
  <code>
  [start of redash/query_runner/sqlite.py]
  1 import logging
  2 import sqlite3
  3 
  4 from redash.query_runner import BaseSQLQueryRunner, register, JobTimeoutException
  5 from redash.utils import json_dumps, json_loads
  6 
  7 logger = logging.getLogger(__name__)
  8 
  9 
  10 class Sqlite(BaseSQLQueryRunner):
  11     noop_query = "pragma quick_check"
  12 
  13     @classmethod
  14     def configuration_schema(cls):
  15         return {
  16             "type": "object",
  17             "properties": {"dbpath": {"type": "string", "title": "Database Path"}},
  18             "required": ["dbpath"],
  19         }
  20 
  21     @classmethod
  22     def type(cls):
  23         return "sqlite"
  24 
  25     def __init__(self, configuration):
  26         super(Sqlite, self).__init__(configuration)
  27 
  28         self._dbpath = self.configuration["dbpath"]
  29 
  30     def _get_tables(self, schema):
  31         query_table = "select tbl_name from sqlite_master where type='table'"
  32         query_columns = "PRAGMA table_info(%s)"
  33 
  34         results, error = self.run_query(query_table, None)
  35 
  36         if error is not None:
  37             raise Exception("Failed getting schema.")
  38 
  39         results = json_loads(results)
  40 
  41         for row in results["rows"]:
  42             table_name = row["tbl_name"]
  43             schema[table_name] = {"name": table_name, "columns": []}
  44             results_table, error = self.run_query(query_columns % (table_name,), None)
  45             if error is not None:
  46                 raise Exception("Failed getting schema.")
  47 
  48             results_table = json_loads(results_table)
  49             for row_column in results_table["rows"]:
  50                 schema[table_name]["columns"].append(row_column["name"])
  51 
  52         return list(schema.values())
  53 
  54     def run_query(self, query, user):
  55         connection = sqlite3.connect(self._dbpath)
  56 
  57         cursor = connection.cursor()
  58 
  59         try:
  60             cursor.execute(query)
  61 
  62             if cursor.description is not None:
  63                 columns = self.fetch_columns([(i[0], None) for i in cursor.description])
  64                 rows = [
  65                     dict(zip((column["name"] for column in columns), row))
  66                     for row in cursor
  67                 ]
  68 
  69                 data = {"columns": columns, "rows": rows}
  70                 error = None
  71                 json_data = json_dumps(data)
  72             else:
  73                 error = "Query completed but it returned no data."
  74                 json_data = None
  75         except (KeyboardInterrupt, JobTimeoutException):
  76             connection.cancel()
  77             raise
  78         finally:
  79             connection.close()
  80         return json_data, error
  81 
  82 
  83 register(Sqlite)
  84
  [end of redash/query_runner/sqlite.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/redash/query_runner/sqlite.py b/redash/query_runner/sqlite.py
  --- a/redash/query_runner/sqlite.py
  +++ b/redash/query_runner/sqlite.py
  @@ -29,7 +29,7 @@
   
       def _get_tables(self, schema):
           query_table = "select tbl_name from sqlite_master where type='table'"
  -        query_columns = "PRAGMA table_info(%s)"
  +        query_columns = "PRAGMA table_info(\"%s\")"
   
           results, error = self.run_query(query_table, None)
  
verification_info: {"golden_diff": "diff --git a/redash/query_runner/sqlite.py b/redash/query_runner/sqlite.py\n--- a/redash/query_runner/sqlite.py\n+++ b/redash/query_runner/sqlite.py\n@@ -29,7 +29,7 @@\n \n     def _get_tables(self, schema):\n         query_table = \"select tbl_name from sqlite_master where type='table'\"\n-        query_columns = \"PRAGMA table_info(%s)\"\n+        query_columns = \"PRAGMA table_info(\\\"%s\\\")\"\n \n         results, error = self.run_query(query_table, None)\n", "issue": "Loading schema for Sqlite DB with \"Order\" column name fails\n### Issue Summary\r\n\r\nI added a Sqlite Database which has an column with the name `Order`.\r\nWhen I try to create a query, the error `Schema refresh failed.` comes up.\r\n\r\n### Steps to Reproduce\r\n\r\n1. Add an Sqlite Database which has a column with the name `Order`\r\n2. Try to create a query\r\n3. Get the error `Schema refresh failed.`\r\n\r\n\r\n### Technical details:\r\n\r\n* Redash Version: cloned from master\r\n* Browser/OS: Brave Browser & Ubuntu 18.1\r\n* How did you install Redash: built from source\r\n\n", "before_files": [{"content": "import logging\nimport sqlite3\n\nfrom redash.query_runner import BaseSQLQueryRunner, register, JobTimeoutException\nfrom redash.utils import json_dumps, json_loads\n\nlogger = logging.getLogger(__name__)\n\n\nclass Sqlite(BaseSQLQueryRunner):\n    noop_query = \"pragma quick_check\"\n\n    @classmethod\n    def configuration_schema(cls):\n        return {\n            \"type\": \"object\",\n            \"properties\": {\"dbpath\": {\"type\": \"string\", \"title\": \"Database Path\"}},\n            \"required\": [\"dbpath\"],\n        }\n\n    @classmethod\n    def type(cls):\n        return \"sqlite\"\n\n    def __init__(self, configuration):\n        super(Sqlite, self).__init__(configuration)\n\n        self._dbpath = self.configuration[\"dbpath\"]\n\n    def _get_tables(self, schema):\n        query_table = \"select tbl_name from sqlite_master where type='table'\"\n        query_columns = \"PRAGMA table_info(%s)\"\n\n        results, error = self.run_query(query_table, None)\n\n        if error is not None:\n            raise Exception(\"Failed getting schema.\")\n\n        results = json_loads(results)\n\n        for row in results[\"rows\"]:\n            table_name = row[\"tbl_name\"]\n            schema[table_name] = {\"name\": table_name, \"columns\": []}\n            results_table, error = self.run_query(query_columns % (table_name,), None)\n            if error is not None:\n                raise Exception(\"Failed getting schema.\")\n\n            results_table = json_loads(results_table)\n            for row_column in results_table[\"rows\"]:\n                schema[table_name][\"columns\"].append(row_column[\"name\"])\n\n        return list(schema.values())\n\n    def run_query(self, query, user):\n        connection = sqlite3.connect(self._dbpath)\n\n        cursor = connection.cursor()\n\n        try:\n            cursor.execute(query)\n\n            if cursor.description is not None:\n                columns = self.fetch_columns([(i[0], None) for i in cursor.description])\n                rows = [\n                    dict(zip((column[\"name\"] for column in columns), row))\n                    for row in cursor\n                ]\n\n                data = {\"columns\": columns, \"rows\": rows}\n                error = None\n                json_data = json_dumps(data)\n            else:\n                error = \"Query completed but it returned no data.\"\n                json_data = None\n        except (KeyboardInterrupt, JobTimeoutException):\n            connection.cancel()\n            raise\n        finally:\n            connection.close()\n        return json_data, error\n\n\nregister(Sqlite)\n", "path": "redash/query_runner/sqlite.py"}]}