oracle / python-oracledb

Python driver for Oracle Database conforming to the Python DB API 2.0 specification. This is the renamed, new major release of cx_Oracle
https://oracle.github.io/python-oracledb
Other
307 stars 59 forks source link

Conflicting examples in JSON type direct binding #350

Open ryotayamanaka opened 1 week ago

ryotayamanaka commented 1 week ago

What is the link to the documentation section that needs improving?

"Using the Oracle Database 21c JSON Type in python-oracledb" section and its example (json_direct.py).

Describe the confusion

The following examples are using the dictionary differently.

    data = [
      (5, dict(name="Sally", dept="Sales", location="France")),
    ]
...
    cursor.execute(insert_sql, [1, data])
    data = dict(name="Rod", dept="Sales", location="Germany")
...
    cursor.execute(insert_sql, [1, data])

Suggest changes that would help

I hope to know which is the right way. Thank you.

cjbj commented 1 week ago

Thanks for reporting the concern.

Use the examples in https://github.com/oracle/python-oracledb/tree/main/samples because they run. Which file and code path to use depends on your table definition and your DB version (and the client version, if you are using Thick mode).

We'll fix the documentation code snippet.