title: How to store mySQL query result into pandas DataFrame with pymysql?
body: <p>I'm trying to store a mySQL query result in a pandas DataFrame using <code>pymysql</code> and am running into errors building the dataframe. Found a similar question <a href="https://stackoverflow.com/questions/43151779/exporting-sql-query-results-to-pandas-dataframe">here</a> and <a href="https://stackoverflow.com/questions/12047193/how-to-convert-sql-query-result-to-pandas-data-structure">here</a>, but it looks like there are <code>pymysql</code>-specific errors being thrown:</p>
  
  <pre><code>import pandas as pd
  import datetime
  import pymysql
  
  # dummy values 
  connection = pymysql.connect(user='username', password='password', databse='database_name', host='host')
  
  start_date = datetime.datetime(2017,11,15)
  end_date = datetime.datetime(2017,11,16)
  
  try:
      with connection.cursor() as cursor:
      query = "SELECT * FROM orders WHERE date_time BETWEEN %s AND %s"
  
      cursor.execute(query, (start_date, end_date)) 
  
      df = pd.DataFrame(data=cursor.fetchall(), index = None, columns = cursor.keys())
  finally:
      connection.close()
  </code></pre>
  
  <p>returns: <code>AttributeError: 'Cursor' object has no attribute 'keys'</code></p>
  
  <p>If I drop the <code>index</code> and <code>columns</code> arguments:</p>
  
  <pre><code>try:
      with connection.cursor() as cursor:
      query = "SELECT * FROM orders WHERE date_time BETWEEN %s AND %s"
  
      cursor.execute(query, (start_date, end_date)) 
  
      df = pd.DataFrame(cursor.fetchall())
  finally:
      connection.close()
  </code></pre>
  
  <p>returns <code>ValueError: DataFrame constructor not properly called!</code></p>
  
  <p>Thanks in advance!</p>