Skip to content

DPY-3013 #291

Closed
Closed

Description

@sfanghaenel
  1. What versions are you using?
    oracledb.version:

Linux-3.10.0-1160.105.1.el7.x86_64-x86_64-with-glibc2.17
True
3.9.18

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

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

Hallo when i try executmany into a table i got the following error:
DPY-3013 unsupported Python type int for database type DB_TYPE_VARCHAR

I try to insert values into a table.
first i create e Table via:
CREATE TABLE (Name1 NUMBER(10), Name2 NUMBER(2))
everything works fine
after this i try to insert values in batches/chunks (each 10000)
The first iteration is fine with execute many
INSERT INTO (Name1, Name2) values (values for Name1, values for Name2)
Important: all values for Column Name2 are None in the first batch!
In the next batch/chunk:
all values for Column Name2 are None except the last 200 (from 9800-10000) are Integers between 0-6
in the executemany statement i ve got the above error.
What I am doing wrong?
Thanx Sven

python skript
import numpy as np
import oracledb

oracledb.init_oracle_client()
con = oracledb.connect(user=env.USER_MD_WSP,
password=env.PWD,
dsn=env.DNS)
cur = con.cursor()

sql = "CREATE TABLE TB_BUG (NAME1 NUMBER(10), NAME2 NUMBER(2))"
cur.execute(sql)
con.commit()

batch1 = [(n, None) for n in range(10000)]
sql = "insert into TB_BUG (NAME1, NAME2) values (:1, :2)"
cur.executemany(sql, batch1, batcherrors=True)
con.commit()

batch2 = [(n, None) for n in range(9000)]
batch2_1 = [(n, np.random.randint(0, 6)) for n in range(1000)]
batch2_all = batch2 + batch2_1
sql = "insert into TB_BUG (NAME1, NAME2) values (:1, :2)"
cur.executemany(sql, batch2_all, batcherrors=True)
con.commit()

Activity

  1. added
    bug
    on Feb 5, 2024
  2. added
    question
    and removed
    bug
    on Feb 12, 2024
  3. anthony-tuininga commented on Feb 12, 2024

    @anthony-tuininga
    Member

    This is not a bug but expected behavior. If you call executemany() and all of the values are NULL, then the driver assumes that the value is of type DB_TYPE_VARCHAR with length 1. When you call it again with some values that are integers the driver complains because you can't assign integers to DB_TYPE_VARCHAR. If you have this situation you need to call cursor.setinputsizes() like the following:

    cur.setinputsizes(int, int)     # or cur.setinputsizes(oracledb.DB_TYPE_NUMBER, oracledb.DB_TYPE_NUMBER)

    That will tell the driver that you intend to store integers (numbers) and the value null (None) can still be assigned.

  4. sfanghaenel commented on Feb 13, 2024

    @sfanghaenel
    Author

    Thanx for your Answer.
    This behavior is a little bit strange because i define the Datatype explicit as a Number(2) in the create Table statement.
    Some times i have a big Table with many rows and columns (20.000.000 x 200) with different Datatypes. Often are Null values in the first 1.000.00 rows in some columns. Than i run in this error. How can i fix this error?
    Do i have to declare the Datytypes before:
    e.G. Table with 4 Columns with Datatypes:
    Varchar2(20), Number(10), Number(2), Varchar2(5)
    cur.setinputsizes(?,?,?,?)
    Thanx Sven

  5. anthony-tuininga commented on Feb 13, 2024

    @anthony-tuininga
    Member

    When performing an insert there is no way for the driver to know anything about the data unless you supply that information! If the data types are not known by your application and you don't mind incurring a round trip to the database to figure that out you can perform a query against the table you are inserting into and look at the metadata that is returned in Cursor.description, then make a call to Cursor.setinputsizes() as needed. This is necessary when you have so many null values as there is no way to differentiate between None intended for a NUMBER column and None intended for a DATE column and None intended for a VARCHAR2 column!

  6. HayDegha0917 commented on Feb 22, 2024

    @HayDegha0917

    Is the driver attempting to insert None values as VACHAR2(1)? My naive assumption is that None is the equivalent of NULL, which can be inserted into any non-null column.

  7. anthony-tuininga commented on Feb 25, 2024

    @anthony-tuininga
    Member

    Yes, None is the equivalent of NULL which can be inserted into any column. The problem is that if you supply a None value there is no way to know the type of that data -- so the driver simply assumes VARCHAR2(1). You can avoid that assumption by using Cursor.setinputsizes().

  8. anthony-tuininga commented on Mar 11, 2024

    @anthony-tuininga
    Member

    I will close this under the assumption that your question has been answered. If not, please feel free to re-open!

  9. avmcohen commented on Feb 6, 2025

    @avmcohen

    Just note that the same binding works fine in cx_Oracle. Just in oracledb it is required

  10. anthony-tuininga commented on Feb 6, 2025

    @anthony-tuininga
    Member

    Just note that the same binding works fine in cx_Oracle. Just in oracledb it is required

    That seems highly unlikely. Please open a new issue with a test case demonstrating the issue!

  11. anthony-tuininga commented on Dec 16, 2025

    @anthony-tuininga
    Member

    Someone else reported this issue and provided a test case that demonstrated the problem. I will get this corrected!

  12. added
    bug
    and removed
    question
    on Dec 16, 2025
  13. anthony-tuininga commented on Dec 23, 2025

    @anthony-tuininga
    Member

    I have pushed a patch that should correct this issue and have initated a build from which you can download pre-built development wheels once it completes. You can also build from source if you prefer. If you can test your scenario and confirm the patch works as expected, that would be appreciated!

  14. anthony-tuininga commented on Jan 23, 2026

    @anthony-tuininga
    Member

    I have initiated a new build on the v3.4.x branch in preparation for the release of python-oracledb 3.4.2.

  15. anthony-tuininga commented on Jan 28, 2026

    @anthony-tuininga
    Member

    This was included in python-oracledb 3.4.2 which was just released.

  16. qbabor4 commented on Jan 29, 2026

    @qbabor4

    I can confirm that version 3.4.2 no longer produces
    oracledb.exceptions.NotSupportedError: DPY-3013: unsupported Python type datetime for database type DB_TYPE_VARCHAR
    when using cursor.executemany() .
    setinputsizes() was not necessary.

  17. talibtahir commented on Jan 31, 2026

    @talibtahir

    I facing same issue

  18. anthony-tuininga commented on Jan 31, 2026

    @anthony-tuininga
    Member

    Upgrade to python-oracledb 3.4.2? Or if you are still facing it with that version, open a new issue providing details!

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpatch available

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions