Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AsyncCursor cannot bind long string to clob parameter #441

Open
klymenkosergiy opened this issue Jan 10, 2025 · 2 comments
Open

AsyncCursor cannot bind long string to clob parameter #441

klymenkosergiy opened this issue Jan 10, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@klymenkosergiy
Copy link

  1. What versions are you using?

platform.platform: Windows-10-10.0.22631-SP0
sys.maxsize > 2**32: True
platform.python_version: 3.9.13
oracledb-2.5.1

Oracle 19/21

  1. Is it an error or a hang or a crash?
    code crash with an exception

  2. What error(s) or behavior you are seeing?
    RuntimeWarning: coroutine 'AsyncConnection.createlob' was never awaited
    await self._impl.execute(self)
    RuntimeWarning: Enable tracemalloc to get the object allocation traceback
    Traceback (most recent call last):
    File "XXX\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
    File "XXX\lib\runpy.py", line 87, in run_code
    exec(code, run_globals)
    File "c:\program files\microsoft visual studio\2022\community\common7\ide\extensions\microsoft\python\core\debugpy_main
    .py", line 71, in
    cli.main()
    File "c:\program files\microsoft visual studio\2022\community\common7\ide\extensions\microsoft\python\core\debugpy/..\debugpy\server\cli.py", line 501, in main
    run()
    File "c:\program files\microsoft visual studio\2022\community\common7\ide\extensions\microsoft\python\core\debugpy/..\debugpy\server\cli.py", line 351, in run_file
    runpy.run_path(target, run_name="main")
    File "c:\program files\microsoft visual studio\2022\community\common7\ide\extensions\microsoft\python\core\debugpy_vendored\pydevd_pydevd_bundle\pydevd_runpy.py", line 310, in run_path
    return _run_module_code(code, init_globals, run_name, pkg_name=pkg_name, script_name=fname)
    File "c:\program files\microsoft visual studio\2022\community\common7\ide\extensions\microsoft\python\core\debugpy_vendored\pydevd_pydevd_bundle\pydevd_runpy.py", line 127, in _run_module_code
    _run_code(code, mod_globals, init_globals, mod_name, mod_spec, pkg_name, script_name)
    File "c:\program files\microsoft visual studio\2022\community\common7\ide\extensions\microsoft\python\core\debugpy_vendored\pydevd_pydevd_bundle\pydevd_runpy.py", line 118, in _run_code
    exec(code, run_globals)
    File "YYYY\Oracledb_Issies.py", line 18, in
    asyncio.run(main())
    File "XXX\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
    File "XXX\lib\asyncio\base_events.py", line 647, in run_until_complete
    return future.result()
    File "YYYY\Oracledb_Issies.py", line 14, in main
    await cur.execute(""" begin test1(p_prm => :clobprm); end;""",
    File "XXX\lib\site-packages\oracledb\cursor.py", line 964, in execute
    await self._impl.execute(self)
    File "src\oracledb\impl/thin/cursor.pyx", line 280, in execute
    File "src\oracledb\impl/thin/cursor.pyx", line 124, in oracledb.thin_impl.BaseThinCursorImpl._preprocess_execute
    File "src\oracledb\impl/base/cursor.pyx", line 352, in oracledb.base_impl.BaseCursorImpl._perform_binds
    File "src\oracledb\impl/thin/var.pyx", line 78, in oracledb.thin_impl.ThinVarImpl._bind
    AttributeError: 'coroutine' object has no attribute 'write'

  1. Does your application call init_oracle_client()?
    no
  1. Include a runnable Python script that shows the problem.

The simple procedure in DB:
create or replace procedure test1(p_prm clob) as
begin
null;
end test1;

import oracledb
import asyncio

async def main():
pool = oracledb.create_pool_async(dsn = "XXX")
con = await pool.acquire()
async with con.cursor() as cur:
await cur.execute(""" begin test1(p_prm => :clobprm); end;""",
clobprm = '123'*20000)
asyncio.run(main())

@klymenkosergiy klymenkosergiy added the bug Something isn't working label Jan 10, 2025
@cjbj
Copy link
Member

cjbj commented Jan 13, 2025

Thanks for the report and test case.

@anthony-tuininga
Copy link
Member

I can confirm that this is indeed a bug. You can do this, in the meantime:

lob = await conn.createlob(oracledb.DB_TYPE_CLOB, "123" * 20000)
await cur.execute("begin test1(p_prm => :clobprm); end;", clobprm=lob)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants