We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
install to msaccess error
When I try to install a dataset to msaccess I get the error:
Couldn't create table (no module named 'pypyodbc')

I've tried doing "pip install pypyodbc --upgrade" which seems to work, but doesn't help with the retriever error.

I'm on a windows 10 machine

--- 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/msaccess.py`
Content:
```
1 from __future__ import print_function
2 from builtins import str
3 import os
4 from retriever.lib.models import Engine, no_cleanup
5 from retriever import DATA_DIR, current_platform
6 
7 
8 class engine(Engine):
9     """Engine instance for Microsoft Access."""
10     name = "Microsoft Access"
11     instructions = """Create a database in Microsoft Access, close Access, then \nselect your database file using this dialog."""
12     abbreviation = "msaccess"
13     datatypes = {
14         "auto": "AUTOINCREMENT",
15         "int": "INTEGER",
16         "bigint": "INTEGER",
17         "double": "NUMERIC",
18         "decimal": "NUMERIC",
19         "char": "VARCHAR",
20         "bool": "BIT",
21     }
22     required_opts = [("file",
23                       "Enter the filename of your Access database",
24                       os.path.join(DATA_DIR, "access.mdb"),
25                       "Access databases (*.mdb, *.accdb)|*.mdb;*.accdb"),
26                      ("table_name",
27                       "Format of table name",
28                       "[{db} {table}]"),
29                      ]
30 
31     def convert_data_type(self, datatype):
32         """MS Access can't handle complex Decimal types"""
33         converted = Engine.convert_data_type(self, datatype)
34         if "NUMERIC" in converted:
35             converted = "NUMERIC"
36         elif "VARCHAR" in converted:
37             try:
38                 length = int(converted.split('(')[1].split(')')[0].split(',')[0])
39                 if length > 255:
40                     converted = "TEXT"
41             except:
42                 pass
43         return converted
44 
45     def create_db(self):
46         """MS Access doesn't create databases."""
47         return None
48 
49     def drop_statement(self, objecttype, objectname):
50         """Returns a drop table or database SQL statement."""
51         dropstatement = "DROP %s %s" % (objecttype, objectname)
52         return dropstatement
53 
54     def insert_data_from_file(self, filename):
55         """Perform a bulk insert."""
56         self.get_cursor()
57         ct = len([True for c in self.table.columns if c[1][0][:3] == "ct-"]) != 0
58         if ((self.table.cleanup.function == no_cleanup and not self.table.fixed_width and
59              self.table.header_rows < 2)
60             and (self.table.delimiter in ["\t", ","])
61             and not ct
62             and (not hasattr(self.table, "do_not_bulk_insert") or not self.table.do_not_bulk_insert)
63             ):
64             print ("Inserting data from " + os.path.basename(filename) + "...")
65 
66             if self.table.delimiter == "\t":
67                 fmt = "TabDelimited"
68             elif self.table.delimiter == ",":
69                 fmt = "CSVDelimited"
70 
71             if self.table.header_rows == 1:
72                 hdr = "Yes"
73             else:
74                 hdr = "No"
75 
76             columns = self.table.get_insert_columns()
77 
78             need_to_delete = False
79             add_to_record_id = 0
80 
81             if self.table.pk and not self.table.contains_pk:
82                 if '.' in os.path.basename(filename):
83                     proper_name = filename.split('.')
84                     newfilename = '.'.join((proper_name[0:-1]) if len(proper_name) > 0 else proper_name[0]
85                                            ) + "_new." + filename.split(".")[-1]
86                 else:
87                     newfilename = filename + "_new"
88 
89                 if not os.path.isfile(newfilename):
90                     print("Adding index to " + os.path.abspath(newfilename) + "...")
91                     read = open(filename, "rb")
92                     write = open(newfilename, "wb")
93                     to_write = ""
94 
95                     for line in read:
96                         to_write += str(id) + self.table.delimiter + line.replace("\n", "\r\n")
97                         add_to_record_id += 1
98                     self.table.record_id += add_to_record_id
99 
100                     write.write(to_write)
101                     write.close()
102                     read.close()
103                     need_to_delete = True
104                 columns = "record_id, " + columns
105             else:
106                 newfilename = filename
107 
108             newfilename = os.path.abspath(newfilename)
109             filename_length = (len(os.path.basename(newfilename)) * -1) - 1
110             filepath = newfilename[:filename_length]
111             statement = """
112 INSERT INTO """ + self.table_name() + " (" + columns + """)
113 SELECT * FROM [""" + os.path.basename(newfilename) + ''']
114 IN "''' + filepath + '''" "Text;FMT=''' + fmt + ''';HDR=''' + hdr + ''';"'''
115 
116             try:
117                 self.execute(statement)
118             except:
119                 print("Couldn't bulk insert. Trying manual insert.")
120                 self.connection.rollback()
121 
122                 self.table.record_id -= add_to_record_id
123 
124                 return Engine.insert_data_from_file(self, filename)
125 
126             if need_to_delete:
127                 os.remove(newfilename)
128 
129         else:
130             return Engine.insert_data_from_file(self, filename)
131 
132     def table_exists(self, dbname, tablename):
133         """Determine if the table already exists in the database"""
134         if not hasattr(self, 'existing_table_names'):
135             self.existing_table_names = set()
136             for row in self.cursor.tables():
137                 tableinfo = row[2]
138                 if not tableinfo.startswith("MSys"):
139                     # ignore system tables
140                     database, table = tableinfo.split()
141                     self.existing_table_names.add((database, table))
142         return self.table_name(name=tablename, dbname=dbname).lower() in self.existing_table_names
143 
144     def get_connection(self):
145         """Gets the db connection."""
146         if current_platform != "windows":
147             raise Exception("MS Access can only be used in Windows.")
148         import pypyodbc as dbapi
149         self.get_input()
150         if not os.path.exists(self.opts['file']) and self.opts['file'].endswith('.mdb'):
151             dbapi.win_create_mdb(self.opts['file'])
152         connection_string = ("DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=" +
153                              os.path.abspath(self.opts["file"]).replace("/", "//") + ";")
154         return dbapi.connect(connection_string, autocommit=False)
155
```

Path: `setup.py`
Content:
```
1 """Use the following command to install retriever: python setup.py install"""
2 from __future__ import absolute_import
3 import platform
4 import os
5 from setuptools import setup
6 from pkg_resources import parse_version
7 
8 current_platform = platform.system().lower()
9 extra_includes = []
10 
11 if os.path.exists(".git/hooks"):  # check if we are in git repo
12     os.system("cp hooks/pre-commit .git/hooks/pre-commit")
13     os.system("chmod +x .git/hooks/pre-commit")
14 
15 
16 __version__ = 'v2.1.dev'
17 with open(os.path.join("retriever", "_version.py"), "w") as version_file:
18     version_file.write("__version__ = " + "'" + __version__ + "'\n")
19     version_file.close()
20 
21 
22 def clean_version(v):
23     return parse_version(v).__repr__().lstrip("<Version('").rstrip("')>")
24 
25 packages = [
26     'retriever.lib',
27     'retriever.engines',
28     'retriever',
29 ]
30 
31 includes = [
32     'xlrd',
33     'future',
34     'argcomplete',
35     'pymysql',
36     'psycopg2',
37     'sqlite3',
38 ] + extra_includes
39 
40 excludes = [
41     'pyreadline',
42     'doctest',
43     'pickle',
44     'pdb',
45     'pywin', 'pywin.debugger',
46     'pywin.debugger.dbgcon',
47     'pywin.dialogs', 'pywin.dialogs.list',
48     'Tkconstants', 'Tkinter', 'tcl', 'tk'
49 ]
50 
51 setup(name='retriever',
52       version=clean_version(__version__),
53       description='Data Retriever',
54       author='Ben Morris, Akash Goel, Henry Senyondo, Ethan White',
55       author_email='ethan@weecology.org',
56       url='https://github.com/weecology/retriever',
57       classifiers=['Intended Audience :: Science/Research',
58                    'License :: OSI Approved :: MIT License',
59                    'Programming Language :: Python',
60                    'Programming Language :: Python :: 2',
61                    'Programming Language :: Python :: 3', ],
62       packages=packages,
63       package_dir={
64           'retriever': 'retriever'
65       },
66       entry_points={
67           'console_scripts': [
68               'retriever = retriever.__main__:main',
69           ],
70       },
71       install_requires=[
72           'xlrd',
73           'future',
74           'argcomplete'
75       ],
76 
77       # py2app flags
78       app=['__main__.py'],
79       data_files=[('', ['CITATION'])],
80       setup_requires=[],
81       )
82 
83 # windows doesn't have bash. No point in using bash-completion
84 if current_platform != "windows":
85     # if platform is OS X use "~/.bash_profile"
86     if current_platform == "darwin":
87         bash_file = "~/.bash_profile"
88     # if platform is Linux use "~/.bashrc
89     elif current_platform == "linux":
90         bash_file = "~/.bashrc"
91     # else write and discard
92     else:
93         bash_file = "/dev/null"
94 
95     argcomplete_command = 'eval "$(register-python-argcomplete retriever)"'
96     with open(os.path.expanduser(bash_file), "a+") as bashrc:
97         bashrc.seek(0)
98         # register retriever for arg-completion if not already registered
99         # whenever a new shell is spawned
100         if argcomplete_command not in bashrc.read():
101             bashrc.write(argcomplete_command + "\n")
102             bashrc.close()
103     os.system("activate-global-python-argcomplete")
104     # register for the current shell
105     os.system(argcomplete_command)
106 
107 try:
108     from retriever.compile import compile
109     from retriever.lib.repository import check_for_updates
110     compile()
111     check_for_updates()
112 except:
113     pass
114
```
--- 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()

```

diff --git a/retriever/engines/msaccess.py b/retriever/engines/msaccess.py
--- a/retriever/engines/msaccess.py
+++ b/retriever/engines/msaccess.py
@@ -27,6 +27,7 @@
                       "Format of table name",
                       "[{db} {table}]"),
                      ]
+    placeholder = "?"
 
     def convert_data_type(self, datatype):
         """MS Access can't handle complex Decimal types"""
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -7,6 +7,8 @@
 
 current_platform = platform.system().lower()
 extra_includes = []
+if current_platform == "windows":
+    extra_includes = ["pypyodbc"]
 
 if os.path.exists(".git/hooks"):  # check if we are in git repo
     os.system("cp hooks/pre-commit .git/hooks/pre-commit")

{"golden_diff": "diff --git a/retriever/engines/msaccess.py b/retriever/engines/msaccess.py\n--- a/retriever/engines/msaccess.py\n+++ b/retriever/engines/msaccess.py\n@@ -27,6 +27,7 @@\n                       \"Format of table name\",\n                       \"[{db} {table}]\"),\n                      ]\n+    placeholder = \"?\"\n \n     def convert_data_type(self, datatype):\n         \"\"\"MS Access can't handle complex Decimal types\"\"\"\ndiff --git a/setup.py b/setup.py\n--- a/setup.py\n+++ b/setup.py\n@@ -7,6 +7,8 @@\n \n current_platform = platform.system().lower()\n extra_includes = []\n+if current_platform == \"windows\":\n+    extra_includes = [\"pypyodbc\"]\n \n if os.path.exists(\".git/hooks\"):  # check if we are in git repo\n     os.system(\"cp hooks/pre-commit .git/hooks/pre-commit\")\n", "issue": "install to msaccess error\nWhen I try to install a dataset to msaccess I get the error:\r\nCouldn't create table (no module named 'pypyodbc')\r\n\r\nI've tried doing \"pip install pypyodbc --upgrade\" which seems to work, but doesn't help with the retriever error.\r\n\r\nI'm on a windows 10 machine\n", "before_files": [{"content": "from __future__ import print_function\nfrom builtins import str\nimport os\nfrom retriever.lib.models import Engine, no_cleanup\nfrom retriever import DATA_DIR, current_platform\n\n\nclass engine(Engine):\n    \"\"\"Engine instance for Microsoft Access.\"\"\"\n    name = \"Microsoft Access\"\n    instructions = \"\"\"Create a database in Microsoft Access, close Access, then \\nselect your database file using this dialog.\"\"\"\n    abbreviation = \"msaccess\"\n    datatypes = {\n        \"auto\": \"AUTOINCREMENT\",\n        \"int\": \"INTEGER\",\n        \"bigint\": \"INTEGER\",\n        \"double\": \"NUMERIC\",\n        \"decimal\": \"NUMERIC\",\n        \"char\": \"VARCHAR\",\n        \"bool\": \"BIT\",\n    }\n    required_opts = [(\"file\",\n                      \"Enter the filename of your Access database\",\n                      os.path.join(DATA_DIR, \"access.mdb\"),\n                      \"Access databases (*.mdb, *.accdb)|*.mdb;*.accdb\"),\n                     (\"table_name\",\n                      \"Format of table name\",\n                      \"[{db} {table}]\"),\n                     ]\n\n    def convert_data_type(self, datatype):\n        \"\"\"MS Access can't handle complex Decimal types\"\"\"\n        converted = Engine.convert_data_type(self, datatype)\n        if \"NUMERIC\" in converted:\n            converted = \"NUMERIC\"\n        elif \"VARCHAR\" in converted:\n            try:\n                length = int(converted.split('(')[1].split(')')[0].split(',')[0])\n                if length > 255:\n                    converted = \"TEXT\"\n            except:\n                pass\n        return converted\n\n    def create_db(self):\n        \"\"\"MS Access doesn't create databases.\"\"\"\n        return None\n\n    def drop_statement(self, objecttype, objectname):\n        \"\"\"Returns a drop table or database SQL statement.\"\"\"\n        dropstatement = \"DROP %s %s\" % (objecttype, objectname)\n        return dropstatement\n\n    def insert_data_from_file(self, filename):\n        \"\"\"Perform a bulk insert.\"\"\"\n        self.get_cursor()\n        ct = len([True for c in self.table.columns if c[1][0][:3] == \"ct-\"]) != 0\n        if ((self.table.cleanup.function == no_cleanup and not self.table.fixed_width and\n             self.table.header_rows < 2)\n            and (self.table.delimiter in [\"\\t\", \",\"])\n            and not ct\n            and (not hasattr(self.table, \"do_not_bulk_insert\") or not self.table.do_not_bulk_insert)\n            ):\n            print (\"Inserting data from \" + os.path.basename(filename) + \"...\")\n\n            if self.table.delimiter == \"\\t\":\n                fmt = \"TabDelimited\"\n            elif self.table.delimiter == \",\":\n                fmt = \"CSVDelimited\"\n\n            if self.table.header_rows == 1:\n                hdr = \"Yes\"\n            else:\n                hdr = \"No\"\n\n            columns = self.table.get_insert_columns()\n\n            need_to_delete = False\n            add_to_record_id = 0\n\n            if self.table.pk and not self.table.contains_pk:\n                if '.' in os.path.basename(filename):\n                    proper_name = filename.split('.')\n                    newfilename = '.'.join((proper_name[0:-1]) if len(proper_name) > 0 else proper_name[0]\n                                           ) + \"_new.\" + filename.split(\".\")[-1]\n                else:\n                    newfilename = filename + \"_new\"\n\n                if not os.path.isfile(newfilename):\n                    print(\"Adding index to \" + os.path.abspath(newfilename) + \"...\")\n                    read = open(filename, \"rb\")\n                    write = open(newfilename, \"wb\")\n                    to_write = \"\"\n\n                    for line in read:\n                        to_write += str(id) + self.table.delimiter + line.replace(\"\\n\", \"\\r\\n\")\n                        add_to_record_id += 1\n                    self.table.record_id += add_to_record_id\n\n                    write.write(to_write)\n                    write.close()\n                    read.close()\n                    need_to_delete = True\n                columns = \"record_id, \" + columns\n            else:\n                newfilename = filename\n\n            newfilename = os.path.abspath(newfilename)\n            filename_length = (len(os.path.basename(newfilename)) * -1) - 1\n            filepath = newfilename[:filename_length]\n            statement = \"\"\"\nINSERT INTO \"\"\" + self.table_name() + \" (\" + columns + \"\"\")\nSELECT * FROM [\"\"\" + os.path.basename(newfilename) + ''']\nIN \"''' + filepath + '''\" \"Text;FMT=''' + fmt + ''';HDR=''' + hdr + ''';\"'''\n\n            try:\n                self.execute(statement)\n            except:\n                print(\"Couldn't bulk insert. Trying manual insert.\")\n                self.connection.rollback()\n\n                self.table.record_id -= add_to_record_id\n\n                return Engine.insert_data_from_file(self, filename)\n\n            if need_to_delete:\n                os.remove(newfilename)\n\n        else:\n            return Engine.insert_data_from_file(self, filename)\n\n    def table_exists(self, dbname, tablename):\n        \"\"\"Determine if the table already exists in the database\"\"\"\n        if not hasattr(self, 'existing_table_names'):\n            self.existing_table_names = set()\n            for row in self.cursor.tables():\n                tableinfo = row[2]\n                if not tableinfo.startswith(\"MSys\"):\n                    # ignore system tables\n                    database, table = tableinfo.split()\n                    self.existing_table_names.add((database, table))\n        return self.table_name(name=tablename, dbname=dbname).lower() in self.existing_table_names\n\n    def get_connection(self):\n        \"\"\"Gets the db connection.\"\"\"\n        if current_platform != \"windows\":\n            raise Exception(\"MS Access can only be used in Windows.\")\n        import pypyodbc as dbapi\n        self.get_input()\n        if not os.path.exists(self.opts['file']) and self.opts['file'].endswith('.mdb'):\n            dbapi.win_create_mdb(self.opts['file'])\n        connection_string = (\"DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=\" +\n                             os.path.abspath(self.opts[\"file\"]).replace(\"/\", \"//\") + \";\")\n        return dbapi.connect(connection_string, autocommit=False)\n", "path": "retriever/engines/msaccess.py"}, {"content": "\"\"\"Use the following command to install retriever: python setup.py install\"\"\"\nfrom __future__ import absolute_import\nimport platform\nimport os\nfrom setuptools import setup\nfrom pkg_resources import parse_version\n\ncurrent_platform = platform.system().lower()\nextra_includes = []\n\nif os.path.exists(\".git/hooks\"):  # check if we are in git repo\n    os.system(\"cp hooks/pre-commit .git/hooks/pre-commit\")\n    os.system(\"chmod +x .git/hooks/pre-commit\")\n\n\n__version__ = 'v2.1.dev'\nwith open(os.path.join(\"retriever\", \"_version.py\"), \"w\") as version_file:\n    version_file.write(\"__version__ = \" + \"'\" + __version__ + \"'\\n\")\n    version_file.close()\n\n\ndef clean_version(v):\n    return parse_version(v).__repr__().lstrip(\"<Version('\").rstrip(\"')>\")\n\npackages = [\n    'retriever.lib',\n    'retriever.engines',\n    'retriever',\n]\n\nincludes = [\n    'xlrd',\n    'future',\n    'argcomplete',\n    'pymysql',\n    'psycopg2',\n    'sqlite3',\n] + extra_includes\n\nexcludes = [\n    'pyreadline',\n    'doctest',\n    'pickle',\n    'pdb',\n    'pywin', 'pywin.debugger',\n    'pywin.debugger.dbgcon',\n    'pywin.dialogs', 'pywin.dialogs.list',\n    'Tkconstants', 'Tkinter', 'tcl', 'tk'\n]\n\nsetup(name='retriever',\n      version=clean_version(__version__),\n      description='Data Retriever',\n      author='Ben Morris, Akash Goel, Henry Senyondo, Ethan White',\n      author_email='ethan@weecology.org',\n      url='https://github.com/weecology/retriever',\n      classifiers=['Intended Audience :: Science/Research',\n                   'License :: OSI Approved :: MIT License',\n                   'Programming Language :: Python',\n                   'Programming Language :: Python :: 2',\n                   'Programming Language :: Python :: 3', ],\n      packages=packages,\n      package_dir={\n          'retriever': 'retriever'\n      },\n      entry_points={\n          'console_scripts': [\n              'retriever = retriever.__main__:main',\n          ],\n      },\n      install_requires=[\n          'xlrd',\n          'future',\n          'argcomplete'\n      ],\n\n      # py2app flags\n      app=['__main__.py'],\n      data_files=[('', ['CITATION'])],\n      setup_requires=[],\n      )\n\n# windows doesn't have bash. No point in using bash-completion\nif current_platform != \"windows\":\n    # if platform is OS X use \"~/.bash_profile\"\n    if current_platform == \"darwin\":\n        bash_file = \"~/.bash_profile\"\n    # if platform is Linux use \"~/.bashrc\n    elif current_platform == \"linux\":\n        bash_file = \"~/.bashrc\"\n    # else write and discard\n    else:\n        bash_file = \"/dev/null\"\n\n    argcomplete_command = 'eval \"$(register-python-argcomplete retriever)\"'\n    with open(os.path.expanduser(bash_file), \"a+\") as bashrc:\n        bashrc.seek(0)\n        # register retriever for arg-completion if not already registered\n        # whenever a new shell is spawned\n        if argcomplete_command not in bashrc.read():\n            bashrc.write(argcomplete_command + \"\\n\")\n            bashrc.close()\n    os.system(\"activate-global-python-argcomplete\")\n    # register for the current shell\n    os.system(argcomplete_command)\n\ntry:\n    from retriever.compile import compile\n    from retriever.lib.repository import check_for_updates\n    compile()\n    check_for_updates()\nexcept:\n    pass\n", "path": "setup.py"}], "after_files": [{"content": "from __future__ import print_function\nfrom builtins import str\nimport os\nfrom retriever.lib.models import Engine, no_cleanup\nfrom retriever import DATA_DIR, current_platform\n\n\nclass engine(Engine):\n    \"\"\"Engine instance for Microsoft Access.\"\"\"\n    name = \"Microsoft Access\"\n    instructions = \"\"\"Create a database in Microsoft Access, close Access, then \\nselect your database file using this dialog.\"\"\"\n    abbreviation = \"msaccess\"\n    datatypes = {\n        \"auto\": \"AUTOINCREMENT\",\n        \"int\": \"INTEGER\",\n        \"bigint\": \"INTEGER\",\n        \"double\": \"NUMERIC\",\n        \"decimal\": \"NUMERIC\",\n        \"char\": \"VARCHAR\",\n        \"bool\": \"BIT\",\n    }\n    required_opts = [(\"file\",\n                      \"Enter the filename of your Access database\",\n                      os.path.join(DATA_DIR, \"access.mdb\"),\n                      \"Access databases (*.mdb, *.accdb)|*.mdb;*.accdb\"),\n                     (\"table_name\",\n                      \"Format of table name\",\n                      \"[{db} {table}]\"),\n                     ]\n    placeholder = \"?\"\n\n    def convert_data_type(self, datatype):\n        \"\"\"MS Access can't handle complex Decimal types\"\"\"\n        converted = Engine.convert_data_type(self, datatype)\n        if \"NUMERIC\" in converted:\n            converted = \"NUMERIC\"\n        elif \"VARCHAR\" in converted:\n            try:\n                length = int(converted.split('(')[1].split(')')[0].split(',')[0])\n                if length > 255:\n                    converted = \"TEXT\"\n            except:\n                pass\n        return converted\n\n    def create_db(self):\n        \"\"\"MS Access doesn't create databases.\"\"\"\n        return None\n\n    def drop_statement(self, objecttype, objectname):\n        \"\"\"Returns a drop table or database SQL statement.\"\"\"\n        dropstatement = \"DROP %s %s\" % (objecttype, objectname)\n        return dropstatement\n\n    def insert_data_from_file(self, filename):\n        \"\"\"Perform a bulk insert.\"\"\"\n        self.get_cursor()\n        ct = len([True for c in self.table.columns if c[1][0][:3] == \"ct-\"]) != 0\n        if ((self.table.cleanup.function == no_cleanup and not self.table.fixed_width and\n             self.table.header_rows < 2)\n            and (self.table.delimiter in [\"\\t\", \",\"])\n            and not ct\n            and (not hasattr(self.table, \"do_not_bulk_insert\") or not self.table.do_not_bulk_insert)\n            ):\n            print (\"Inserting data from \" + os.path.basename(filename) + \"...\")\n\n            if self.table.delimiter == \"\\t\":\n                fmt = \"TabDelimited\"\n            elif self.table.delimiter == \",\":\n                fmt = \"CSVDelimited\"\n\n            if self.table.header_rows == 1:\n                hdr = \"Yes\"\n            else:\n                hdr = \"No\"\n\n            columns = self.table.get_insert_columns()\n\n            need_to_delete = False\n            add_to_record_id = 0\n\n            if self.table.pk and not self.table.contains_pk:\n                if '.' in os.path.basename(filename):\n                    proper_name = filename.split('.')\n                    newfilename = '.'.join((proper_name[0:-1]) if len(proper_name) > 0 else proper_name[0]\n                                           ) + \"_new.\" + filename.split(\".\")[-1]\n                else:\n                    newfilename = filename + \"_new\"\n\n                if not os.path.isfile(newfilename):\n                    print(\"Adding index to \" + os.path.abspath(newfilename) + \"...\")\n                    read = open(filename, \"rb\")\n                    write = open(newfilename, \"wb\")\n                    to_write = \"\"\n\n                    for line in read:\n                        to_write += str(id) + self.table.delimiter + line.replace(\"\\n\", \"\\r\\n\")\n                        add_to_record_id += 1\n                    self.table.record_id += add_to_record_id\n\n                    write.write(to_write)\n                    write.close()\n                    read.close()\n                    need_to_delete = True\n                columns = \"record_id, \" + columns\n            else:\n                newfilename = filename\n\n            newfilename = os.path.abspath(newfilename)\n            filename_length = (len(os.path.basename(newfilename)) * -1) - 1\n            filepath = newfilename[:filename_length]\n            statement = \"\"\"\nINSERT INTO \"\"\" + self.table_name() + \" (\" + columns + \"\"\")\nSELECT * FROM [\"\"\" + os.path.basename(newfilename) + ''']\nIN \"''' + filepath + '''\" \"Text;FMT=''' + fmt + ''';HDR=''' + hdr + ''';\"'''\n\n            try:\n                self.execute(statement)\n            except:\n                print(\"Couldn't bulk insert. Trying manual insert.\")\n                self.connection.rollback()\n\n                self.table.record_id -= add_to_record_id\n\n                return Engine.insert_data_from_file(self, filename)\n\n            if need_to_delete:\n                os.remove(newfilename)\n\n        else:\n            return Engine.insert_data_from_file(self, filename)\n\n    def table_exists(self, dbname, tablename):\n        \"\"\"Determine if the table already exists in the database\"\"\"\n        if not hasattr(self, 'existing_table_names'):\n            self.existing_table_names = set()\n            for row in self.cursor.tables():\n                tableinfo = row[2]\n                if not tableinfo.startswith(\"MSys\"):\n                    # ignore system tables\n                    database, table = tableinfo.split()\n                    self.existing_table_names.add((database, table))\n        return self.table_name(name=tablename, dbname=dbname).lower() in self.existing_table_names\n\n    def get_connection(self):\n        \"\"\"Gets the db connection.\"\"\"\n        if current_platform != \"windows\":\n            raise Exception(\"MS Access can only be used in Windows.\")\n        import pypyodbc as dbapi\n        self.get_input()\n        if not os.path.exists(self.opts['file']) and self.opts['file'].endswith('.mdb'):\n            dbapi.win_create_mdb(self.opts['file'])\n        connection_string = (\"DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=\" +\n                             os.path.abspath(self.opts[\"file\"]).replace(\"/\", \"//\") + \";\")\n        return dbapi.connect(connection_string, autocommit=False)\n", "path": "retriever/engines/msaccess.py"}, {"content": "\"\"\"Use the following command to install retriever: python setup.py install\"\"\"\nfrom __future__ import absolute_import\nimport platform\nimport os\nfrom setuptools import setup\nfrom pkg_resources import parse_version\n\ncurrent_platform = platform.system().lower()\nextra_includes = []\nif current_platform == \"windows\":\n    extra_includes = [\"pypyodbc\"]\n\nif os.path.exists(\".git/hooks\"):  # check if we are in git repo\n    os.system(\"cp hooks/pre-commit .git/hooks/pre-commit\")\n    os.system(\"chmod +x .git/hooks/pre-commit\")\n\n\n__version__ = 'v2.1.dev'\nwith open(os.path.join(\"retriever\", \"_version.py\"), \"w\") as version_file:\n    version_file.write(\"__version__ = \" + \"'\" + __version__ + \"'\\n\")\n    version_file.close()\n\n\ndef clean_version(v):\n    return parse_version(v).__repr__().lstrip(\"<Version('\").rstrip(\"')>\")\n\npackages = [\n    'retriever.lib',\n    'retriever.engines',\n    'retriever',\n]\n\nincludes = [\n    'xlrd',\n    'future',\n    'argcomplete',\n    'pymysql',\n    'psycopg2',\n    'sqlite3',\n] + extra_includes\n\nexcludes = [\n    'pyreadline',\n    'doctest',\n    'pickle',\n    'pdb',\n    'pywin', 'pywin.debugger',\n    'pywin.debugger.dbgcon',\n    'pywin.dialogs', 'pywin.dialogs.list',\n    'Tkconstants', 'Tkinter', 'tcl', 'tk'\n]\n\nsetup(name='retriever',\n      version=clean_version(__version__),\n      description='Data Retriever',\n      author='Ben Morris, Akash Goel, Henry Senyondo, Ethan White',\n      author_email='ethan@weecology.org',\n      url='https://github.com/weecology/retriever',\n      classifiers=['Intended Audience :: Science/Research',\n                   'License :: OSI Approved :: MIT License',\n                   'Programming Language :: Python',\n                   'Programming Language :: Python :: 2',\n                   'Programming Language :: Python :: 3', ],\n      packages=packages,\n      package_dir={\n          'retriever': 'retriever'\n      },\n      entry_points={\n          'console_scripts': [\n              'retriever = retriever.__main__:main',\n          ],\n      },\n      install_requires=[\n          'xlrd',\n          'future',\n          'argcomplete'\n      ],\n\n      # py2app flags\n      app=['__main__.py'],\n      data_files=[('', ['CITATION'])],\n      setup_requires=[],\n      )\n\n# windows doesn't have bash. No point in using bash-completion\nif current_platform != \"windows\":\n    # if platform is OS X use \"~/.bash_profile\"\n    if current_platform == \"darwin\":\n        bash_file = \"~/.bash_profile\"\n    # if platform is Linux use \"~/.bashrc\n    elif current_platform == \"linux\":\n        bash_file = \"~/.bashrc\"\n    # else write and discard\n    else:\n        bash_file = \"/dev/null\"\n\n    argcomplete_command = 'eval \"$(register-python-argcomplete retriever)\"'\n    with open(os.path.expanduser(bash_file), \"a+\") as bashrc:\n        bashrc.seek(0)\n        # register retriever for arg-completion if not already registered\n        # whenever a new shell is spawned\n        if argcomplete_command not in bashrc.read():\n            bashrc.write(argcomplete_command + \"\\n\")\n            bashrc.close()\n    os.system(\"activate-global-python-argcomplete\")\n    # register for the current shell\n    os.system(argcomplete_command)\n\ntry:\n    from retriever.compile import compile\n    from retriever.lib.repository import check_for_updates\n    compile()\n    check_for_updates()\nexcept:\n    pass\n", "path": "setup.py"}]}