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

cx_oracle allows me to insert pyodbc.row object or objects in executemany() and execute. oracledb does not! #205

Closed
hl1 opened this issue Jul 19, 2023 · 5 comments
Labels
bug Something isn't working patch available

Comments

@hl1
Copy link

hl1 commented Jul 19, 2023

  1. What versions are you using?

V.1.3.1 on windows and linux

  1. Is it an error or a hang or a crash?

error

  1. What error(s) or behavior you are seeing?

DPY-2004: "parameters" argument should be a list of sequences or dictionaries, or an integer specifying the number of times to execute the statement

  1. Does your application call init_oracle_client()?
    does not work regardless if it is thin or thick mode.

  2. Include a runnable Python script that shows the problem.

import pyodbc
cnxn = pyodbc.connect('DRIVER={SQL Server};SERVER=SQLSRV01;DATABASE=DATABASE;UID=USER;PWD=PASSWORD')
cursor = cnxn.cursor()
cursor.execute("SELECT 1, 2 UNION SELECT 3, 4")
results = cursor.fetchall()

with oracledb.connect(user=un, password=pw, dsn=cs) as connection:
    with connection.cursor() as oracle_cursor:
        oracle_cursor.executemany("insert into ParentTable values (:1, :2)", results)

I get the following error on the last line:
DPY-2004: "parameters" argument should be a list of sequences or dictionaries, or an integer specifying the number of times to execute the statement

more info:

type(results) -- returns <class 'list'>
type(results[0]) -- return <class 'pyodbc.Row'>

This works with no problem in cx_oracle!

@hl1 hl1 added the bug Something isn't working label Jul 19, 2023
@hl1
Copy link
Author

hl1 commented Jul 19, 2023

workaround for those encountering similar issues is to convert pyodbc rows into regular list:

results = [list(row) for row in cursor.fetchall())]

but I am not looking for a workaround, I need a solution for this as pyodbc.rows are more powerful than a regular list. and converting a huge stack of code to the workaround above should be temporary and not the final solution.

@anthony-tuininga
Copy link
Member

I have pushed a patch that should correct this issue. If you are able to build from source you can verify that it corrects your issue as well.

@SmileyMan
Copy link

results = [list(row) for row in cursor.fetchall())]

Thank you. Just changing from cx_Oracle to oracledb and hit the same issue.

@hl1
Copy link
Author

hl1 commented Aug 8, 2023

I have pushed a patch that should correct this issue. If you are able to build from source you can verify that it corrects your issue as well.

I am not able to build from source but will be waiting on this to be released in future oracledb version

@anthony-tuininga
Copy link
Member

This has been included in python-oracledb 1.4.0 which was just released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working patch available
Projects
None yet
Development

No branches or pull requests

3 participants