I am using pyscopg2
and have a method that returns a list based on a SQL query. The below works fine...
def checkAnalysisStartDate(self):
session = self.connection()
cursor = session.cursor()
ids = self.getAnalysisIds() # this is a list of integers
cursor.execute("select start_date from analysis_run_history where analysis_id in %s", [tuple(ids)])
final_result = [i[0] for i in cursor.fetchall()]
I want to pass the same list of integers but this time return a DataFrame
from the results. When I try this though....
import pandas.io.sql as sqlio
def getAnalysisMetaStatsDF(self):
session = self.connection()
ids = self.getAnalysisIds() # this is a list of integers
data = sqlio.read_sql_query("Select * from analysis_stats where analysis_id in %s", [tuple(ids)], session)
print(data)
I get back...
AttributeError: 'list' object has no attribute 'cursor'
I think it's something with the way I am passing the parameters to read_sql_query()
but I am not sure how to fix it