You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+31-8Lines changed: 31 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,8 @@ Easy to use , buy may not the best practice for efficiency concern.
18
18
pip install cx_Oracle_async
19
19
20
20
## Usage
21
-
- Nearly all the same with aiomysql (with very limited functions of cource)
21
+
- Nearly all the same with aiomysql (with very limited functions of cource).
22
+
- If you're connecting to database which is on a different machine with python process , you need to install oracle client module in order to use this library. Check [cx-Oracle's installation guide](https://cx-oracle.readthedocs.io/en/latest/user_guide/installation.html).
22
23
- No automaticly date format transition built-in.
23
24
24
25
## Performance
@@ -33,24 +34,22 @@ single line insertion | N/A (todo) | N/A | N/A
33
34
*Oracle 19c*<br>
34
35
*You can find performance test codes [here](https://github.com/GoodManWEN/cx_Oracle_async/blob/main/misc).*
35
36
36
-
## Example
37
+
## Examples
38
+
Before running examples , make sure you've already installed a [oracle client](https://github.com/GoodManWEN/cx_Oracle_async#usage) on your machine.
37
39
```Python3
38
40
# all_usages.py
39
41
import asyncio
40
42
import cx_Oracle_async
41
43
42
44
asyncdefmain():
43
-
loop = asyncio.get_running_loop()
44
45
oracle_pool =await cx_Oracle_async.create_pool(
45
46
host='localhost',
46
47
port='1521',
47
48
user='user',
48
49
password='password',
49
-
db='orcl',
50
-
loop=loop,
51
-
autocommit=False, # this option has no use.
52
-
minsize=2,
53
-
maxsize=4,
50
+
service_name='orcl',
51
+
min=2,
52
+
max=4,
54
53
)
55
54
56
55
asyncwith oracle_pool.acquire() as connection:
@@ -74,6 +73,30 @@ async def main():
74
73
await cursor.execute(sql_3 , (60 , ))
75
74
print(await cursor.fetchall())
76
75
76
+
await oracle_pool.close()
77
+
77
78
if__name__=='__main__':
78
79
asyncio.run(main())
79
80
```
81
+
82
+
Or you can connect to database via makedsn style:
83
+
```Python3
84
+
# makedsn.py
85
+
import asyncio
86
+
import cx_Oracle_async
87
+
88
+
asyncdefmain():
89
+
# same api as cx_Oracle.makedsn with 4 limited parameters(host , port , sid , service_name).
0 commit comments