cx_Oracle_async
cx_Oracle_async copied to clipboard
adding cursor.description and cursor.fetchmany()
i added a PR to patch this in https://github.com/GoodManWEN/cx_Oracle_async/pull/25 but incase somone lands up here and PR isnt accepted or delayed then a "sneaky" fix would be to do something like this:
class Cursor():
def __init__(self, baseObject):
self.__class__ = type(baseObject.__class__.__name__,(self.__class__, baseObject.__class__),{})
self.__dict__ = baseObject.__dict__
@property
def description(self):
return self._cursor.description
async def fetchmany(self, *args, **kwargs):
return await self._loop.run_in_executor(self._thread_pool, self._cursor.fetchmany, *args, **kwargs)
and usage would be something like
conn = await self.connection.acquire()
self.cursor = Cursor(await conn.cursor())
(its less than ideal but hey... cowboy thursdays right!)
another issue for description: https://github.com/GoodManWEN/cx_Oracle_async/issues/19
came across a use case that i need to set the outputtypehandler
this works
def output_type_handler(cursor, name, default_type, size, precision, scale):
....
oracle_pool = await cx_Oracle_async.create_pool(...)
async with oracle_pool.acquire() as connection:
async with connection.cursor() as cursor:
cursor._cursor.outputtypehandler = output_type_handler