Skip to content

Commit 73ed700

Browse files
committed
Change api
1 parent fff3dd4 commit 73ed700

File tree

1 file changed

+51
-3
lines changed

1 file changed

+51
-3
lines changed

cx_Oracle_async/utils.py

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from ThreadPoolExecutorPlus import ThreadPoolExecutor
2-
import cx_Oracle as csor
2+
import cx_Oracle as cxor
33
import platform
44
import asyncio
55
import os
@@ -12,6 +12,8 @@
1212
DEFAULT_MAXIMUM_WORKER_NUM = (os.cpu_count() or 1) * 32
1313
DEFAULT_MAXIMUM_WORKER_TIMES = 3
1414

15+
makedsn = cxor.makedsn
16+
1517
class AsyncCursorWrapper:
1618

1719
def __init__(self , loop , thread_pool , cursor):
@@ -115,10 +117,56 @@ def _test():
115117

116118
await self._loop.run_in_executor(self._thread_pool , _test)
117119

118-
async def create_pool(host = 'localhost', port = '1521' , user = 'sys', password = '', db = 'orcl', loop = None, minsize = 2 , maxsize = 4 , encoding = 'UTF-8' , autocommit=False):
120+
async def create_pool(
121+
user=None,
122+
password=None,
123+
dsn=None,
124+
min=2,
125+
max=4,
126+
increment=1,
127+
connectiontype=cxor.Connection,
128+
threaded=True,
129+
getmode=cxor.SPOOL_ATTRVAL_NOWAIT,
130+
events=False,
131+
homogeneous=True,
132+
externalauth=False,
133+
encoding='UTF-8',
134+
edition=None,
135+
timeout=0,
136+
waitTimeout=0,
137+
maxLifetimeSession=0,
138+
sessionCallback=None,
139+
maxSessionsPerShard=0,
140+
host='localhost',
141+
port='1521',
142+
service_name='orcl',
143+
sid=None,
144+
loop=None
145+
):
119146
if loop == None:
120147
loop = asyncio.get_running_loop()
121-
pool = csor.SessionPool(user , password , f"{host}:{port}/{db}", min = minsize , max = maxsize , increment = 1 , threaded = True , encoding = encoding)
148+
if dsn == None:
149+
dsn = makedsn(host = host, port = port, sid = sid , service_name = service_name)
150+
pool = cxor.SessionPool(
151+
user=user,
152+
password=password,
153+
dsn=dsn,
154+
min=min,
155+
max=max,
156+
increment=increment,
157+
connectiontype=connectiontype,
158+
threaded=threaded,
159+
getmode=getmode,
160+
events=events,
161+
homogeneous=homogeneous,
162+
externalauth=externalauth,
163+
encoding=encoding,
164+
edition=edition,
165+
timeout=timeout,
166+
waitTimeout=waitTimeout,
167+
maxLifetimeSession=maxLifetimeSession,
168+
sessionCallback=sessionCallback,
169+
maxSessionsPerShard=maxSessionsPerShard)
122170
pool = AsyncPoolWrapper(pool)
123171
await pool.preexciting()
124172
return pool

0 commit comments

Comments
 (0)