title: Connecting with Athena using Python and pyathenajdbc
body: <p>I am trying to connect to AWS Athena using python. I am trying to use pyathenajdbc to achieve this task. The issue I am having is obtaining a connection. When I run the code below, I receive an error message stating it cannot find the AthenaDriver. ( java.lang.RuntimeException: Class com.amazonaws.athena.jdbc.AthenaDriver not found).  I did download this file from AWS and I have confirmed it is sitting in that directory.</p>
  
  <pre><code>from mdpbi.rsi.config import *
  from mdpbi.tools.functions import mdpLog
  from pkg_resources import resource_string
  import argparse
  import os
  import pyathenajdbc
  import sys
  
  SCRIPT_NAME = "Athena_Export"
  
  ATHENA_JDBC_CLASSPATH = "/opt/amazon/athenajdbc/AthenaJDBC41-1.0.0.jar"
  EXPORT_OUTFILE = "RSI_Export.txt"
  EXPORT_OUTFILE_PATH = os.path.join(WORKINGDIR, EXPORT_OUTFILE)
  
  
  def get_arg_parser():
      """This function returns the argument parser object to be used with this script"""
      parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
  
      return parser
  
  
  def main():
      args = get_arg_parser().parse_args(sys.argv[1:])
      logger = mdpLog(SCRIPT_NAME, LOGDIR)
  
      SQL = resource_string("mdpbi.rsi.athena.resources", "athena.sql")
  
      conn = pyathenajdbc.connect(
          s3_staging_dir="s3://athena",
          access_key=AWS_ACCESS_KEY_ID,
          secret_key=AWS_SECRET_ACCESS_KEY,
          region_name="us-east-1",
          log_path=LOGDIR,
          driver_path=ATHENA_JDBC_CLASSPATH
      )
      try:
          with conn.cursor() as cursor:
              cursor.execute(SQL)
              logger.info(cursor.description)
              logger.info(cursor.fetchall())
      finally:
          conn.close()
  
      return 0
  
  
  if __name__ == '__main__':
      rtn = main()
      sys.exit(rtn)
  </code></pre>
  
  <blockquote>
    <p>Traceback (most recent call last):   File
    "/usr/lib64/python2.7/runpy.py", line 174, in _run_module_as_main
        "<strong>main</strong>", fname, loader, pkg_name)   File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code
        exec code in run_globals   File "/home/ec2-user/jason_testing/mdpbi/rsi/athena/<strong>main</strong>.py", line 53,
    in 
        rtn = main()   File "/home/ec2-user/jason_testing/mdpbi/rsi/athena/<strong>main</strong>.py", line 39,
    in main
        driver_path=athena_jdbc_driver_path   File "/opt/mdpbi/Python_Envs/2.7.10/local/lib/python2.7/dist-packages/pyathenajdbc/<strong>init</strong>.py",
    line 65, in connect
        driver_path, **kwargs)   File "/opt/mdpbi/Python_Envs/2.7.10/local/lib/python2.7/dist-packages/pyathenajdbc/connection.py",
    line 68, in <strong>init</strong>
        jpype.JClass(ATHENA_DRIVER_CLASS_NAME)   File "/opt/mdpbi/Python_Envs/2.7.10/lib64/python2.7/dist-packages/jpype/_jclass.py",
    line 55, in JClass
        raise _RUNTIMEEXCEPTION.PYEXC("Class %s not found" % name)</p>
  </blockquote>