Postgresql – TypeError: 'NoneType' object is not subscriptable while using fetchone()
cur.execute(""" CREATE TEMPORARY VIEW bobby_view AS SELECT heading1, heading2 FROM bobby WHERE heading2 = %s; """, (variable,)) cur.execute(""" SELECT d1.heading1 FROM bobby_view d1 WHERE d1.heading1 >= ALL ( SELECT d2.heading1 FROM bobby_view d2); """) answer = cur.fetchone()[0] This produces the…