oracle / python-cx_Oracle

Python interface to Oracle Database now superseded by python-oracledb
https://oracle.github.io/python-cx_Oracle
Other
889 stars 361 forks source link

Running into ORA-19011: Character string buffer too small when executing fetchmany #645

Closed zhcheng1 closed 1 year ago

zhcheng1 commented 1 year ago

1-2 What versions are you using?

platform.platform: Darwin-21.6.0-x86_64-i386-64bit
sys.maxsize > 2**32: True
platform.python_version: 3.7.10
cx_Oracle.version: 8.0.1
cx_Oracle.clientversion: (12, 2, 0, 1, 0)
  1. Describe the problem I have written a python script to get XML data. The XML data is saved as varchar2 in the database. The error I encountered is about the string buffer. However because the XML data is saved as varchar so it can't exceed the limit. The code is throwing the error at fetchmany. Error:

    ...
    rows = cursor.fetchmany(self._batch_row_num)
    cx_Oracle.DatabaseError: ORA-19011: Character string buffer too small
  2. Include a runnable Python script that shows the problem. part of the script that contains the major logic

    
    import cx_Oracle
    from bs4 import BeautifulSoup
    from cx_Oracle import DatabaseError
    class XMLFetcher(object):
    def __init__(self, connect_string):
        self._batch_row_num = 10
        self._cursor = None
        self._connection = None
        self._connect_string = connect_string
    
        try:
            self._connection = cx_Oracle.connect(self._connect_string, mode=0, threaded=True, encoding="UTF-8", nencoding="UTF-8")
            self._connection.outputtypehandler = self.output_type_handler
    
        except DatabaseError as e:
            print('Exception while trying to initialize database connection object : %s', e)
            raise e
    
    def get_xml(self, table_name, dryrun=False):
        with self._connection.cursor() as cursor:
            cursor.execute("SELECT ID, XMLCOL FROM table1 order by ID ")
            while True:
                rows = cursor.fetchmany(self._batch_row_num)
                ...
zhcheng1 commented 1 year ago

found a dup https://github.com/oracle/python-cx_Oracle/issues/348. closing this issue

stale[bot] commented 1 year ago

This issue has been automatically marked as inactive because it has not been updated recently. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 1 year ago

This issue has been automatically closed because it has not been updated for a month.