New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server-side cursor error when closing before any `execute` is ran #716

Closed
stevebeck89 opened this Issue May 18, 2018 · 0 comments

Comments

Projects
None yet
2 participants
@stevebeck89

stevebeck89 commented May 18, 2018

Server-side cursors throw an exception when close() is called before execute().

It was not obvious what was going wrong when I executed code similar to this

test.py

import psycopg2

conn = psycopg2.connect('user=postgres')

with conn.cursor('server_side_cursor_name') as curs:
	with open('not/there') as f:
		curs.execute('some query')

output

$ python test.py
Traceback (most recent call last):
  File "test.py", line 7, in <module>
    curs.execute('some query')
psycopg2.OperationalError: cursor "server_side_cursor_name" does not exist

Another way to recreate this is simply:

import psycopg2

conn = psycopg2.connect('user=postgres')

with conn.cursor('server_side_cursor_name') as curs:
	pass

dvarrazzo added a commit that referenced this issue May 20, 2018

@dvarrazzo dvarrazzo added this to the psycopg 2.7.5 milestone May 20, 2018

@dvarrazzo dvarrazzo closed this in c4da939 May 20, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment