psql - Executing an insert query on each row in results: psycopg2.ProgrammingError: no results to fetch -


what dumb thing missing here:

>>> cur.execute("select id tracks") >>> row in cur: ...     story = random.choice(fortunes) + random.choice(fortunes) ...     cur.execute("update tracks set story=%s id=%s", (story, row[0])) ...  traceback (most recent call last):   file "<stdin>", line 1, in <module> psycopg2.programmingerror: no results fetch 

but there seem results:

>>> cur.execute("select id tracks") >>> row in cur: ...     print(row) ...  (8,) (45,) (12,) (64,) (1,) (6,) 

looks psycopg2 doesn't allow interleaved queries (although postgresql can it, on end). if initial query isn't huge, simplest solution coalesce results list - change from row in cur: from row in cur.fetchall(): , should right.


Comments

Popular posts from this blog

javascript - three.js lot of meshes optimization -

smartface.io - Proper way to change color scheme for whole application -

Email notification in google apps script -