I am new to postgresql and python. Could you please help me to fix this issue. I am getting undefined column error while fetching with where caluse. PostgreSQL 14 and python 3.8 version has been used.
import psycopg2
con = psycopg2.connect(database="dbname",user="postgres",password="pwd",host="localhost",port= '5432')
cursor_obj = con.cursor()
#print(s3.x)
x = 'select "*" FROM PUBLIC."tab1" '
y = 'where "SSN"="123-45-6789" '
#z = '"123-45-6789"'
a = x + y
cursor_obj.execute(a)
#cursor_obj.execute('SELECT "SSN" FROM PUBLIC."tab1" where "SSN" = "123-45-6789 "')
result = cursor_obj.fetchall()
print("Result set:","\n",result)
con.commit()
con.close()
ere
Error: UndefinedColumn: column "123-45-6789" does not exist LINE 1: ...NFD-SSN" FROM PUBLIC."tab1" where "SSN"="123-45-67...
I tried changing the apostrophes but still didn't work