Код: Выделить всё
def track_exists():
conn = psycopg.connect("dbname=postgres user=postgres password=***)
cur = conn.cursor()
sqltest = "SELECT EXISTS(SELECT 1 FROM CUSTOMERS WHERE CUSTOMERS.PHONE = '608-888-8888')"
cur.execute(sqltest)
result = cur.fetchall()
if result == [(True,)]:
print("working")
dosomething()
elif result == "":
print("not working")
Подробнее здесь: https://stackoverflow.com/questions/790 ... -statement