prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  fetch method should return an ordered dict (not a dict)
  Hello,
  
  I noticed that `fetch` method returns a dict of dataframes.
  To preserve order of tables (which may have a meaning) it should return an ordered dict.
  [Datapackage](https://frictionlessdata.io/specs/data-package/) ressources are stored in a list so it's ordered.
  
  Kind regards
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `retriever/engines/sqlite.py`
  Content:
  ```
  1 import os
  2 import pandas as pd
  3 from builtins import range
  4 
  5 from retriever.lib.defaults import DATA_DIR
  6 from retriever.lib.models import Engine, no_cleanup
  7 
  8 
  9 class engine(Engine):
  10     """Engine instance for SQLite."""
  11 
  12     name = "SQLite"
  13     abbreviation = "sqlite"
  14     datatypes = {
  15         "auto": ("INTEGER", "AUTOINCREMENT"),
  16         "int": "INTEGER",
  17         "bigint": "INTEGER",
  18         "double": "REAL",
  19         "decimal": "REAL",
  20         "char": "TEXT",
  21         "bool": "INTEGER",
  22     }
  23     placeholder = "?"
  24     insert_limit = 1000
  25     required_opts = [("file",
  26                       "Enter the filename of your SQLite database",
  27                       "sqlite.db"),
  28                      ("table_name",
  29                       "Format of table name",
  30                       "{db}_{table}"),
  31                      ("data_dir",
  32                       "Install directory",
  33                       DATA_DIR),
  34                      ]
  35 
  36     def create_db(self):
  37         """Don't create database for SQLite
  38 
  39         SQLite doesn't create databases. Each database is a file and needs a separate
  40         connection. This overloads`create_db` to do nothing in this case.
  41         """
  42         return None
  43 
  44     def fetch_tables(self, dataset, table_names):
  45         """Return sqlite dataset as list of pandas dataframe."""
  46         connection = self.get_connection()
  47         data = {table[len(dataset) + 1:]: pd.read_sql_query("SELECT * "
  48                                                             "FROM {};".format(table),
  49                                                             connection)
  50                 for table in table_names}
  51         return data
  52 
  53     def get_bulk_insert_statement(self):
  54         """Get insert statement for bulk inserts
  55 
  56         This places ?'s instead of the actual values so that executemany() can
  57         operate as designed
  58         """
  59         columns = self.table.get_insert_columns()
  60         column_count = len(self.table.get_insert_columns(False))
  61         insert_stmt = "INSERT INTO " + self.table_name()
  62         insert_stmt += " (" + columns + ")"
  63         insert_stmt += " VALUES ("
  64         for _ in range(0, column_count):
  65             insert_stmt += "?, "
  66         insert_stmt = insert_stmt.rstrip(", ") + ")"
  67         return insert_stmt
  68 
  69     def insert_data_from_file(self, filename):
  70         """Perform a high speed bulk insert
  71 
  72         Checks to see if a given file can be bulk inserted, and if so loads
  73         it in chunks and inserts those chunks into the database using
  74         executemany.
  75         """
  76         chunk_size = 1000000
  77         self.get_cursor()
  78 
  79         # Determine if the dataset includes cross-tab data
  80         crosstab = len([True for c in self.table.columns if c[1][0][:3] == "ct-"]) != 0
  81 
  82         if (([self.table.cleanup.function, self.table.header_rows] == [no_cleanup, 1])
  83             and not self.table.fixed_width
  84             and not crosstab
  85             and (not hasattr(self.table, "do_not_bulk_insert") or not self.table.do_not_bulk_insert)):
  86             filename = os.path.abspath(filename)
  87             try:
  88                 bulk_insert_statement = self.get_bulk_insert_statement()
  89                 line_endings = set(['\n', '\r', '\r\n'])
  90                 with open(filename, 'r') as data_file:
  91                     data_chunk = data_file.readlines(chunk_size)
  92                     data_chunk = [line.rstrip('\r\n') for line in data_chunk if line not in line_endings]
  93                     del data_chunk[:self.table.header_rows]
  94                     while data_chunk:
  95                         data_chunk_split = [row.split(self.table.delimiter)
  96                                             for row in data_chunk]
  97                         self.cursor.executemany(bulk_insert_statement, data_chunk_split)
  98                         data_chunk = data_file.readlines(chunk_size)
  99                 self.connection.commit()
  100             except:
  101                 self.connection.rollback()
  102                 return Engine.insert_data_from_file(self, filename)
  103         else:
  104             return Engine.insert_data_from_file(self, filename)
  105 
  106     def get_connection(self):
  107         """Get db connection."""
  108         import sqlite3 as dbapi
  109 
  110         self.get_input()
  111         file = self.opts["file"]
  112         db_file = self.opts["data_dir"]
  113         full_path = os.path.join(db_file, file)
  114 
  115         return dbapi.connect(os.path.normpath(full_path))
  116
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/retriever/engines/sqlite.py b/retriever/engines/sqlite.py
  --- a/retriever/engines/sqlite.py
  +++ b/retriever/engines/sqlite.py
  @@ -1,6 +1,7 @@
   import os
   import pandas as pd
   from builtins import range
  +from collections import OrderedDict
   
   from retriever.lib.defaults import DATA_DIR
   from retriever.lib.models import Engine, no_cleanup
  @@ -44,10 +45,12 @@
       def fetch_tables(self, dataset, table_names):
           """Return sqlite dataset as list of pandas dataframe."""
           connection = self.get_connection()
  -        data = {table[len(dataset) + 1:]: pd.read_sql_query("SELECT * "
  -                                                            "FROM {};".format(table),
  -                                                            connection)
  -                for table in table_names}
  +        sql_query = "SELECT * FROM {};"
  +        data = OrderedDict({
  +                    table[len(dataset) + 1:]
  +                    :pd.read_sql_query(sql_query.format(table), connection)
  +                    for table in table_names
  +               })
           return data
   
       def get_bulk_insert_statement(self):
  
verification_info: {"golden_diff": "diff --git a/retriever/engines/sqlite.py b/retriever/engines/sqlite.py\n--- a/retriever/engines/sqlite.py\n+++ b/retriever/engines/sqlite.py\n@@ -1,6 +1,7 @@\n import os\n import pandas as pd\n from builtins import range\n+from collections import OrderedDict\n \n from retriever.lib.defaults import DATA_DIR\n from retriever.lib.models import Engine, no_cleanup\n@@ -44,10 +45,12 @@\n     def fetch_tables(self, dataset, table_names):\n         \"\"\"Return sqlite dataset as list of pandas dataframe.\"\"\"\n         connection = self.get_connection()\n-        data = {table[len(dataset) + 1:]: pd.read_sql_query(\"SELECT * \"\n-                                                            \"FROM {};\".format(table),\n-                                                            connection)\n-                for table in table_names}\n+        sql_query = \"SELECT * FROM {};\"\n+        data = OrderedDict({\n+                    table[len(dataset) + 1:]\n+                    :pd.read_sql_query(sql_query.format(table), connection)\n+                    for table in table_names\n+               })\n         return data\n \n     def get_bulk_insert_statement(self):\n", "issue": "fetch method should return an ordered dict (not a dict)\nHello,\r\n\r\nI noticed that `fetch` method returns a dict of dataframes.\r\nTo preserve order of tables (which may have a meaning) it should return an ordered dict.\r\n[Datapackage](https://frictionlessdata.io/specs/data-package/) ressources are stored in a list so it's ordered.\r\n\r\nKind regards\n", "before_files": [{"content": "import os\nimport pandas as pd\nfrom builtins import range\n\nfrom retriever.lib.defaults import DATA_DIR\nfrom retriever.lib.models import Engine, no_cleanup\n\n\nclass engine(Engine):\n    \"\"\"Engine instance for SQLite.\"\"\"\n\n    name = \"SQLite\"\n    abbreviation = \"sqlite\"\n    datatypes = {\n        \"auto\": (\"INTEGER\", \"AUTOINCREMENT\"),\n        \"int\": \"INTEGER\",\n        \"bigint\": \"INTEGER\",\n        \"double\": \"REAL\",\n        \"decimal\": \"REAL\",\n        \"char\": \"TEXT\",\n        \"bool\": \"INTEGER\",\n    }\n    placeholder = \"?\"\n    insert_limit = 1000\n    required_opts = [(\"file\",\n                      \"Enter the filename of your SQLite database\",\n                      \"sqlite.db\"),\n                     (\"table_name\",\n                      \"Format of table name\",\n                      \"{db}_{table}\"),\n                     (\"data_dir\",\n                      \"Install directory\",\n                      DATA_DIR),\n                     ]\n\n    def create_db(self):\n        \"\"\"Don't create database for SQLite\n\n        SQLite doesn't create databases. Each database is a file and needs a separate\n        connection. This overloads`create_db` to do nothing in this case.\n        \"\"\"\n        return None\n\n    def fetch_tables(self, dataset, table_names):\n        \"\"\"Return sqlite dataset as list of pandas dataframe.\"\"\"\n        connection = self.get_connection()\n        data = {table[len(dataset) + 1:]: pd.read_sql_query(\"SELECT * \"\n                                                            \"FROM {};\".format(table),\n                                                            connection)\n                for table in table_names}\n        return data\n\n    def get_bulk_insert_statement(self):\n        \"\"\"Get insert statement for bulk inserts\n\n        This places ?'s instead of the actual values so that executemany() can\n        operate as designed\n        \"\"\"\n        columns = self.table.get_insert_columns()\n        column_count = len(self.table.get_insert_columns(False))\n        insert_stmt = \"INSERT INTO \" + self.table_name()\n        insert_stmt += \" (\" + columns + \")\"\n        insert_stmt += \" VALUES (\"\n        for _ in range(0, column_count):\n            insert_stmt += \"?, \"\n        insert_stmt = insert_stmt.rstrip(\", \") + \")\"\n        return insert_stmt\n\n    def insert_data_from_file(self, filename):\n        \"\"\"Perform a high speed bulk insert\n\n        Checks to see if a given file can be bulk inserted, and if so loads\n        it in chunks and inserts those chunks into the database using\n        executemany.\n        \"\"\"\n        chunk_size = 1000000\n        self.get_cursor()\n\n        # Determine if the dataset includes cross-tab data\n        crosstab = len([True for c in self.table.columns if c[1][0][:3] == \"ct-\"]) != 0\n\n        if (([self.table.cleanup.function, self.table.header_rows] == [no_cleanup, 1])\n            and not self.table.fixed_width\n            and not crosstab\n            and (not hasattr(self.table, \"do_not_bulk_insert\") or not self.table.do_not_bulk_insert)):\n            filename = os.path.abspath(filename)\n            try:\n                bulk_insert_statement = self.get_bulk_insert_statement()\n                line_endings = set(['\\n', '\\r', '\\r\\n'])\n                with open(filename, 'r') as data_file:\n                    data_chunk = data_file.readlines(chunk_size)\n                    data_chunk = [line.rstrip('\\r\\n') for line in data_chunk if line not in line_endings]\n                    del data_chunk[:self.table.header_rows]\n                    while data_chunk:\n                        data_chunk_split = [row.split(self.table.delimiter)\n                                            for row in data_chunk]\n                        self.cursor.executemany(bulk_insert_statement, data_chunk_split)\n                        data_chunk = data_file.readlines(chunk_size)\n                self.connection.commit()\n            except:\n                self.connection.rollback()\n                return Engine.insert_data_from_file(self, filename)\n        else:\n            return Engine.insert_data_from_file(self, filename)\n\n    def get_connection(self):\n        \"\"\"Get db connection.\"\"\"\n        import sqlite3 as dbapi\n\n        self.get_input()\n        file = self.opts[\"file\"]\n        db_file = self.opts[\"data_dir\"]\n        full_path = os.path.join(db_file, file)\n\n        return dbapi.connect(os.path.normpath(full_path))\n", "path": "retriever/engines/sqlite.py"}], "after_files": [{"content": "import os\nimport pandas as pd\nfrom builtins import range\nfrom collections import OrderedDict\n\nfrom retriever.lib.defaults import DATA_DIR\nfrom retriever.lib.models import Engine, no_cleanup\n\n\nclass engine(Engine):\n    \"\"\"Engine instance for SQLite.\"\"\"\n\n    name = \"SQLite\"\n    abbreviation = \"sqlite\"\n    datatypes = {\n        \"auto\": (\"INTEGER\", \"AUTOINCREMENT\"),\n        \"int\": \"INTEGER\",\n        \"bigint\": \"INTEGER\",\n        \"double\": \"REAL\",\n        \"decimal\": \"REAL\",\n        \"char\": \"TEXT\",\n        \"bool\": \"INTEGER\",\n    }\n    placeholder = \"?\"\n    insert_limit = 1000\n    required_opts = [(\"file\",\n                      \"Enter the filename of your SQLite database\",\n                      \"sqlite.db\"),\n                     (\"table_name\",\n                      \"Format of table name\",\n                      \"{db}_{table}\"),\n                     (\"data_dir\",\n                      \"Install directory\",\n                      DATA_DIR),\n                     ]\n\n    def create_db(self):\n        \"\"\"Don't create database for SQLite\n\n        SQLite doesn't create databases. Each database is a file and needs a separate\n        connection. This overloads`create_db` to do nothing in this case.\n        \"\"\"\n        return None\n\n    def fetch_tables(self, dataset, table_names):\n        \"\"\"Return sqlite dataset as list of pandas dataframe.\"\"\"\n        connection = self.get_connection()\n        sql_query = \"SELECT * FROM {};\"\n        data = OrderedDict({\n                    table[len(dataset) + 1:]\n                    :pd.read_sql_query(sql_query.format(table), connection)\n                    for table in table_names\n               })\n        return data\n\n    def get_bulk_insert_statement(self):\n        \"\"\"Get insert statement for bulk inserts\n\n        This places ?'s instead of the actual values so that executemany() can\n        operate as designed\n        \"\"\"\n        columns = self.table.get_insert_columns()\n        column_count = len(self.table.get_insert_columns(False))\n        insert_stmt = \"INSERT INTO \" + self.table_name()\n        insert_stmt += \" (\" + columns + \")\"\n        insert_stmt += \" VALUES (\"\n        for _ in range(0, column_count):\n            insert_stmt += \"?, \"\n        insert_stmt = insert_stmt.rstrip(\", \") + \")\"\n        return insert_stmt\n\n    def insert_data_from_file(self, filename):\n        \"\"\"Perform a high speed bulk insert\n\n        Checks to see if a given file can be bulk inserted, and if so loads\n        it in chunks and inserts those chunks into the database using\n        executemany.\n        \"\"\"\n        chunk_size = 1000000\n        self.get_cursor()\n\n        # Determine if the dataset includes cross-tab data\n        crosstab = len([True for c in self.table.columns if c[1][0][:3] == \"ct-\"]) != 0\n\n        if (([self.table.cleanup.function, self.table.header_rows] == [no_cleanup, 1])\n            and not self.table.fixed_width\n            and not crosstab\n            and (not hasattr(self.table, \"do_not_bulk_insert\") or not self.table.do_not_bulk_insert)):\n            filename = os.path.abspath(filename)\n            try:\n                bulk_insert_statement = self.get_bulk_insert_statement()\n                line_endings = set(['\\n', '\\r', '\\r\\n'])\n                with open(filename, 'r') as data_file:\n                    data_chunk = data_file.readlines(chunk_size)\n                    data_chunk = [line.rstrip('\\r\\n') for line in data_chunk if line not in line_endings]\n                    del data_chunk[:self.table.header_rows]\n                    while data_chunk:\n                        data_chunk_split = [row.split(self.table.delimiter)\n                                            for row in data_chunk]\n                        self.cursor.executemany(bulk_insert_statement, data_chunk_split)\n                        data_chunk = data_file.readlines(chunk_size)\n                self.connection.commit()\n            except:\n                self.connection.rollback()\n                return Engine.insert_data_from_file(self, filename)\n        else:\n            return Engine.insert_data_from_file(self, filename)\n\n    def get_connection(self):\n        \"\"\"Get db connection.\"\"\"\n        import sqlite3 as dbapi\n\n        self.get_input()\n        file = self.opts[\"file\"]\n        db_file = self.opts[\"data_dir\"]\n        full_path = os.path.join(db_file, file)\n\n        return dbapi.connect(os.path.normpath(full_path))\n", "path": "retriever/engines/sqlite.py"}]}