With an SQL query included in a python script, I need to be able to assign each column value (2 columns with only 1 row as an output from query) to a variable like this:
sqlquery = “””SELECT MIN(DATE) AS STARTDATE, MAX(DATE) AS ENDDATE
FROM table”””
cursor.execute(sqlquery)
sqlqueryresult = cursor.fetchall()
sqlqueryresult = list(sqlqueryresult)
STARTDATE, ENDDATE = [sqlqueryresult[i] for i in (1, 2)]
<code>But I'm getting this error: IndexError: list index out of range
What am I doing wrong? Thanks!
</code>
<code>But I'm getting this error: IndexError: list index out of range
What am I doing wrong? Thanks!
</code>
But I'm getting this error: IndexError: list index out of range
What am I doing wrong? Thanks!