I'm trying to pull data from the sql database, but the second part of the code after the case is not readable

Viewed 37

Error in python

enter image description here

Code running in DB

enter image description here

I'm trying to pull data from the sql database, but the second part of the code after the 'case' is not readable. But this one when in sql works, but does not work in Python. Help please

cursor.execute('SELECT  distinct created_date from analitics','case when cast("("created_date")") = cast(now() as DATE) then (Yes) else (No) end FROM analitics')
1 Answers

Your python code is incorrect. Update it as below:

cursor.execute('SELECT  distinct created_date from analitics, case when cast(created_date) = cast(now() as DATE) then "Yes" else "No" end FROM analitics')
Related