Skip to content

ORA-01745 Error When using executemany() to insert #641

@FoolPlayer

Description

@FoolPlayer
  1. What versions are you using?
  • platform.platform: Windows-10-10.0.19041-SP0
  • sys.maxsize > 2**32: True
  • platform.python_version: 3.7.3
  • cx_Oracle.version: 8.3.0
  • cx_Oracle.clientversion: (12, 1, 0, 2, 0)
  1. Describe the problem
  • When I try to use executemany() to insert into the database, the error occured.
    • File ".\test.py", line 52, in
      cur.executemany(sql,data)
      cx_Oracle.DatabaseError: ORA-01745: invalid host/bind variable name
  • the code is
    sql='''insert into "t_file" ("id","uuid","filename","path","size","type") values (:id,:uuid,:filename,:path,:size,:type)'''
    data=[{'id': 1, 'uuid': '9f0c23d', 'filename': '16574g', 'path': 'D:', 'size': 381.21,'type':'2'}]
    cursor.executemany(sql,data)
    And I found if I change the variable 'size' after ':' to another name like ':size1', and also change it in the dict, or just delete the variable named 'size' it works.
    It's so confused, I know 'size' is one of the reserved words of Oracle, but it works when I use the name 'type'.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions