File tree Expand file tree Collapse file tree 1 file changed +27
-6
lines changed
Expand file tree Collapse file tree 1 file changed +27
-6
lines changed Original file line number Diff line number Diff line change @@ -40,17 +40,14 @@ import asyncio
4040import cx_Oracle_async
4141
4242async def main ():
43- loop = asyncio.get_running_loop()
4443 oracle_pool = await cx_Oracle_async.create_pool(
4544 host = ' localhost' ,
4645 port = ' 1521' ,
4746 user = ' user' ,
4847 password = ' password' ,
49- db = ' orcl' ,
50- loop = loop,
51- autocommit = False , # this option has no use.
52- minsize = 2 ,
53- maxsize = 4 ,
48+ service_name = ' orcl' ,
49+ min = 2 ,
50+ max = 4 ,
5451 )
5552
5653 async with oracle_pool.acquire() as connection:
@@ -74,6 +71,30 @@ async def main():
7471 await cursor.execute(sql_3 , (60 , ))
7572 print (await cursor.fetchall())
7673
74+ await oracle_pool.close()
75+
7776if __name__ == ' __main__' :
7877 asyncio.run(main())
7978```
79+
80+ Or you can connect to database via makedsn:
81+ ```
82+ # makedsn.py
83+ import asyncio
84+ import cx_Oracle_async
85+
86+ async def main():
87+ # same api as cx_Oracle.makedsn with 4 limited parameters(host , port , sid , service_name).
88+ dsn = cx_Oracle_async.makedsn(host = 'localhost' , port = '1521' , service_name = 'orcl')
89+ oracle_pool = await cx_Oracle_async.create_pool(
90+ user='user',
91+ password='password',
92+ dsn = dsn
93+ )
94+
95+ ...
96+
97+ await oracle_pool.close()
98+
99+ asyncio.run(main())
100+ ```
You can’t perform that action at this time.
0 commit comments