Kalpit
Kalpit

Reputation: 1101

Selecting rows with a specific column as null gives column does not exist error

I'm using psycopg2, and the query is a simple string.

Q= "SELECT * FROM POST WHERE PUBLISH_TIME IS NULL"

When I execute it in pgAdmin, it gives me the correct results, but throws

psycopg2.ProgrammingError: column "publish_time" does not exist 

I tried this solution but it's still the same error output.

Upvotes: 1

Views: 81

Answers (1)

Kalpit
Kalpit

Reputation: 1101

Leaving this answer here in case anyone has the same problem. This cannot be done via psycopg2 due to a design feature. I added a flag to my model which depended on publish_date column, created a db script that wrote this flag and went ahead with

Q= "SELECT * FROM POST WHERE PUBLISH_FLAG = False;"  

Upvotes: 1

Related Questions