CursorWrapper.executemany is missing param "returning"
Closed this issue · 2 comments
Description
It appears that when using the New Relic agent, the Aurora cursor is being wrapped with CursorWrapper. However, this object seems to be missing the "returning" parameter that is available in the original object, as seen here:
https://www.psycopg.org/psycopg3/docs/api/cursors.html#psycopg.Cursor.executemany
executemany(query: Query, params_seq: Iterable[Params], *, returning: [bool](https://docs.python.org/3/library/functions.html#bool) = False) → [None](https://docs.python.org/3/library/constants.html#None)
Expected Behavior
The program should function the same as it does without the New Relic wrapper, meaning the "returning" parameter should be available for the cursor object.
Steps to Reproduce
Any script that attempts to run a query using executemany with the "returning" parameter (while using the New Relic agent) will fail with the error: "CursorWrapper.executemany() got an unexpected keyword argument 'returning'."
Note: if you will remove the init of newrelic agent (first 2 rows) there won't be any issue.
import newrelic.agent
newrelic.agent.initialize('/opt/app/newrelic.ini')
import psycopg
from psycopg.rows import dict_row
aurora_connection = psycopg.connect(
conninfo="postgresql://XXX:YYY@host.docker.internal:5020/MyAuroraDB", row_factory=dict_row
)
aurora_cursor = aurora_connection.cursor()
aurora_cursor.executemany(
"""INSERT INTO users (name, email) VALUES (%s, %s) RETURNING id;""",
[('Alice', 'alice@example.com'), ('Bob', 'bob@example.com')],
returning=True,
)
Your Environment
docker-image: python:3.11-slim
newrelic: 9.12.0
psycopg: 3.2.1
Thanks for the bug report, this will be fixed in our next release.