Python Forum
Error TypeError: output_type_handler() takes 2 positional arguments but 6 were given
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error TypeError: output_type_handler() takes 2 positional arguments but 6 were given
#1
Hi all, I'm running a python code that was working before with older version. Now using 3.10 I'm gettin error below:

TypeError: output_type_handler() takes 2 positional arguments but 6 were given
The block is below:

return_code = 0

try:
    with tempfile.TemporaryDirectory() as tmp_dir:
        import cx_Oracle as oracledb
        import xml.etree.ElementTree as ET
        import os
        import subprocess

        def output_type_handler(
                cursor,
                default_type):
            if default_type == oracledb.CLOB:
                return cursor.var(
                    oracledb.LONG_STRING,
                    arraysize=cursor.arraysize)
            if default_type == oracledb.BLOB:
                return cursor.var(
                    oracledb.LONG_BINARY,
                    arraysize=cursor.arraysize)

        conn = oracledb.connect("/", mode=oracledb.SYSDBA)
        conn.outputtypehandler = output_type_handler
        prev_name = None
        cursor = conn.cursor()
        cursor.execute(
            "select name, cval from v$view where conftype='XYZ' order by name desc")
I'm returning only 2 columns in query and declared 2 type handler columns so not sure from where it was getting "6 arguments given".
Reply
#2
(Oct-17-2022, 06:23 PM)paulo79 Wrote: Hi all, I'm running a python code that was working before with older version. Now using 3.10 I'm gettin error below:

TypeError: output_type_handler() takes 2 positional arguments but 6 were given
The block is below:

return_code = 0

try:
    with tempfile.TemporaryDirectory() as tmp_dir:
        import cx_Oracle as oracledb
        import xml.etree.ElementTree as ET
        import os
        import subprocess

        def output_type_handler(
                cursor,
                default_type):
            if default_type == oracledb.CLOB:
                return cursor.var(
                    oracledb.LONG_STRING,
                    arraysize=cursor.arraysize)
            if default_type == oracledb.BLOB:
                return cursor.var(
                    oracledb.LONG_BINARY,
                    arraysize=cursor.arraysize)

        conn = oracledb.connect("/", mode=oracledb.SYSDBA)
        conn.outputtypehandler = output_type_handler
        prev_name = None
        cursor = conn.cursor()
        cursor.execute(
            "select name, cval from v$view where conftype='XYZ' order by name desc")
I'm returning only 2 columns in query and declared 2 type handler columns so not sure from where it was getting "6 arguments given".

Pleae ignore. I found the error.

Just had to add all signatures like :

def output_type_handler(cursor, name, default_type, size, precision, scale):
            if default_type == oracledb.DB_TYPE_CLOB:
                return cursor.var(oracledb.DB_TYPE_LONG, arraysize=cursor.arraysize)
            if default_type == oracledb.DB_TYPE_BLOB:
                return cursor.var(oracledb.DB_TYPE_LONG_RAW, arraysize=cursor.arraysize)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  error in class: TypeError: 'str' object is not callable akbarza 2 522 Dec-30-2023, 04:35 PM
Last Post: deanhystad
  [split] Class takes no arguments bily071 2 649 Oct-23-2023, 03:59 PM
Last Post: deanhystad
  boto3 - Error - TypeError: string indices must be integers kpatil 7 1,271 Jun-09-2023, 06:56 PM
Last Post: kpatil
  Error: _vhstack_dispatcher() takes 1 positional argument but 9 were given alexfrol86 3 5,846 May-09-2022, 12:49 PM
Last Post: deanhystad
  "<class 'typeerror'>: don't know how to convert" error GiggsB 3 3,375 Feb-28-2022, 06:45 PM
Last Post: GiggsB
  TypeError: not enough arguments for format string MaartenRo 6 2,946 Jan-09-2022, 06:46 PM
Last Post: ibreeden
  TypeError: sequence item 0: expected str instance, float found Error Query eddywinch82 1 5,137 Sep-04-2021, 09:16 PM
Last Post: eddywinch82
  TypeError: missing 3 required positional arguments: wardancer84 9 10,938 Aug-19-2021, 04:27 PM
Last Post: deanhystad
  TypeError: run_oracle_job() missing 1 required positional argument: 'connection_strin python_student 1 1,977 Aug-06-2021, 08:05 PM
Last Post: SheeppOSU
  Checking the number of arguments a function takes Chirumer 3 2,165 Jul-06-2021, 04:56 PM
Last Post: Chirumer

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020