forked from ibmdb/python-ibmdb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_06_async_iteration.py
More file actions
65 lines (57 loc) · 1.52 KB
/
Copy pathtest_06_async_iteration.py
File metadata and controls
65 lines (57 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
from __future__ import print_function
import asyncio
import sys
import unittest
import config
from ibm_db_dbi import AsyncConnection
from testfunctions import IbmDbTestFunctions
class IbmDbTestCase(unittest.TestCase):
def test_06_async_iteration(self):
obj = IbmDbTestFunctions()
obj.assert_expect(self.run_test_06)
def run_test_06(self):
async def main():
conn = await AsyncConnection.connect(
"DATABASE=%s;HOSTNAME=%s;PORT=%d;PROTOCOL=TCPIP;UID=%s;PWD=%s;" % (
config.database, config.hostname, config.port,
config.user, config.password),
'', '')
cursor = await conn.cursor()
await cursor.execute("SELECT ID, NAME FROM STAFF FETCH FIRST 5 ROWS ONLY")
count = 0
async for row in cursor:
print(row)
count += 1
print("Iterated over %d rows" % count)
await cursor.close()
await conn.close()
asyncio.run(main())
#__END__
#__LUW_EXPECTED__
#(10, 'Sanders')
#(20, 'Pernal')
#(30, 'Marenghi')
#(40, 'OBrien')
#(50, 'Hanes')
#Iterated over 5 rows
#__ZOS_EXPECTED__
#(10, 'Sanders')
#(20, 'Pernal')
#(30, 'Marenghi')
#(40, 'OBrien')
#(50, 'Hanes')
#Iterated over 5 rows
#__SYSTEMI_EXPECTED__
#(10, 'Sanders')
#(20, 'Pernal')
#(30, 'Marenghi')
#(40, 'OBrien')
#(50, 'Hanes')
#Iterated over 5 rows
#__IDS_EXPECTED__
#(10, 'Sanders')
#(20, 'Pernal')
#(30, 'Marenghi')
#(40, 'OBrien')
#(50, 'Hanes')
#Iterated over 5 rows