title: How do I import an .accdb file into Python and use the data?
body: <p>I am trying to figure out a way to create a program that allows me to find the best combination of data based on several different factors. </p>
  
  <p>I have a Microsoft Access file with creature data in it. Attack, Defense, Health, Required Battle skill to use and several other bits of info.</p>
  
  <p>I am trying to import this .accdb (Access 2013) file and be able to access the stored data. </p>
  
  <p>I am going to try to make a program that scans all the data and runs all possible combinations (sets of 5 creatures) to find the strongest combination of creatures for different required battle skills (ex: 100 battle skill would use creature 1, 2, 3, 4 and 5 where 125 battle skill would use creature 3, 5, 6, 8, and 10)</p>
  
  <p>The main thing I need help with first is being able to import the data base for easy access so I do not have to recreate the data in python and so I can use the same program for new access databases in the future. </p>
  
  <p>I have installed <a href="https://code.google.com/p/pypyodbc/" rel="noreferrer">https://code.google.com/p/pypyodbc/</a> but can't seem to figure out how to get it to load an existing file.</p>
  
  <h2>Edit</h2>
  
  <p>I tried to use the code from Gord's answer, modified to fit my info. </p>
  
  <pre class="lang-python prettyprint-override"><code># -*- coding: utf-8 -*-
  import pypyodbc
  pypyodbc.lowercase = False
  conn = pypyodbc.connect(
      r"Driver={Microsoft Access Driver (*.mdb, *.accdb)};" +
      r"Dbq=C:\Users\Ju\Desktop\Dark Summoner.accdb;")
  cur = conn.cursor()
  cur.execute("SELECT Number, Name, Atk, Def, HP, BP, Species, Special FROM Impulse AA+");
  while True:
      row = cur.fetchone()
      if row is None:
          break
      print (u"Creature with Number {1} is {1} ({2})".format(
          row.get("CreatureID"), row.get("Name_EN"), row.get("Name_JP")))
  cur.close()
  conn.close()
  </code></pre>
  
  
  
  <p>Was getting an error with the print line so added () around it. </p>
  
  <p>I am now getting this error, similar to what I was getting in the past. </p>
  
  <pre class="lang-python prettyprint-override"><code>Traceback (most recent call last):
    File "C:\Users\Ju\Desktop\Test.py", line 6, in &lt;module&gt;
      r"Dbq=C:\Users\Ju\Desktop\Dark Summoner.accdb;")
    File "C:\Python34\lib\site-packages\pypyodbc-1.3.3-py3.4.egg\pypyodbc.py", line 2434, in __init__
      self.connect(connectString, autocommit, ansi, timeout, unicode_results, readonly)
    File "C:\Python34\lib\site-packages\pypyodbc-1.3.3-py3.4.egg\pypyodbc.py", line 2483, in connect
      check_success(self, ret)
    File "C:\Python34\lib\site-packages\pypyodbc-1.3.3-py3.4.egg\pypyodbc.py", line 988, in check_success
      ctrl_err(SQL_HANDLE_DBC, ODBC_obj.dbc_h, ret, ODBC_obj.ansi)
    File "C:\Python34\lib\site-packages\pypyodbc-1.3.3-py3.4.egg\pypyodbc.py", line 964, in ctrl_err
      raise Error(state,err_text)
  pypyodbc.Error: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified')
  </code></pre>
  
  <p>I looked through the pypyodbc.py file at the lines mentioned in the error code, but could not figure it out. I tried to remove the "r" from the beginning of r"Driver={Microsoft Access Driver (*.mdb, *.accdb)};" and tried a space between r and "Driver because I did not know what it was for, But got a different error. </p>
  
  <h2>Edit</h2>
  
  <p>I checked my files as suggested. I believe I am running 64bit. I checked both the 32 bit and 64 bit versions. I have Microsoft Access Driver (*.mdb, *.accdb) in the 64 bit but not in the 32 bit. I am using the 2013 version of Microsoft Visual Studios.</p>
  
  <h2>Edit</h2>
  
  <p>Working now!</p>
  
  <p>My final working code in case it helps anyone in the future. </p>
  
  <pre class="lang-python prettyprint-override"><code># -*- coding: utf-8 -*-
  import pypyodbc
  pypyodbc.lowercase = False
  conn = pypyodbc.connect(
      r"Driver={Microsoft Access Driver (*.mdb, *.accdb)};" +
      r"Dbq=C:\Users\Ju\Desktop\Dark Summoner.accdb;")
  cur = conn.cursor()
  cur.execute("SELECT Number, ID, Name, Atk, Def, HP, BP, Species, Special FROM Impulse_AA");
  while True:
      row = cur.fetchone()
      if row is None:
          break
      print (u"ID: {1} {2} Atk:{3} Def:{4} HP:{5} BP:{6} Species: {7} {8}".format(
          row.get("Number"), row.get("ID"), row.get("Name"), row.get("Atk"),
          row.get("Def"), row.get("HP"), row.get("BP"), row.get("Species"), row.get("Special") ))
  cur.close()
  conn.close()
  </code></pre>