Skip to content
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

Prepared statement fails for INSERT operation #59

Closed
czechnology opened this issue Jan 19, 2021 · 1 comment
Closed

Prepared statement fails for INSERT operation #59

czechnology opened this issue Jan 19, 2021 · 1 comment

Comments

@czechnology
Copy link

>>> ps = conn.prepare("INSERT INTO record (domain_name) VALUES (:domain_name)")
>>> ps.run(domain_name="example.com")
Traceback (most recent call last):
  File "/home/user/.local/lib/python3.7/site-packages/pg8000/core.py", line 1587, in run
    name_bin, row_desc, input_funcs = self.name_map[oids]
KeyError: (705,)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/.local/lib/python3.7/site-packages/pg8000/core.py", line 1590, in run
    self.con.prepare_statement(self.operation, oids)
  File "/home/user/.local/lib/python3.7/site-packages/pg8000/core.py", line 1274, in prepare_statement
    return statement_name_bin, cursor.row_desc, cursor.input_funcs
AttributeError: 'Cursor' object has no attribute 'input_funcs'

I'm not entirely sure what are the Cursor.input_funcs for but the field is missing by default - maybe an empty tuple should be added in the Cursor constructor?
I was only able to run the INSERT prepared statement if first running e.g. a SELECT command, which populates the input_funcs.

@tlocke
Copy link
Owner

tlocke commented Jan 31, 2021

Hi @czechnology, this should be fixed in version 1.17.0. Let me know if it's still a problem though.

@tlocke tlocke closed this as completed Jan 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants