File tree Expand file tree Collapse file tree 2 files changed +21
-21
lines changed
Expand file tree Collapse file tree 2 files changed +21
-21
lines changed Original file line number Diff line number Diff line change @@ -89,14 +89,14 @@ def query_data():
8989 session = session_pool .get_session ()
9090
9191 print ("get data from root.test.d0" )
92- res = session .execute_query_statement ("select * from root.test.d0" )
93- while res .has_next ():
94- print (res .next ())
92+ with session .execute_query_statement ("select * from root.test.d0" ) as res :
93+ while res .has_next ():
94+ print (res .next ())
9595
9696 print ("get data from root.test.d1" )
97- res = session .execute_query_statement ("select * from root.test.d1" )
98- while res .has_next ():
99- print (res .next ())
97+ with session .execute_query_statement ("select * from root.test.d1" ) as res :
98+ while res .has_next ():
99+ print (res .next ())
100100
101101 session_pool .put_back (session )
102102
@@ -105,9 +105,9 @@ def delete_data():
105105 session = session_pool .get_session ()
106106 session .delete_storage_group (STORAGE_GROUP_NAME )
107107 print ("data has been deleted. now the devices are:" )
108- res = session .execute_statement ("show devices root.test.**" )
109- while res .has_next ():
110- print (res .next ())
108+ with session .execute_statement ("show devices root.test.**" ) as res :
109+ while res .has_next ():
110+ print (res .next ())
111111 session_pool .put_back (session )
112112
113113
Original file line number Diff line number Diff line change @@ -44,9 +44,9 @@ def prepare_data():
4444
4545 print ("now the tables are:" )
4646 # show result
47- res = session .execute_query_statement ("SHOW TABLES" )
48- while res .has_next ():
49- print (res .next ())
47+ with session .execute_query_statement ("SHOW TABLES" ) as res :
48+ while res .has_next ():
49+ print (res .next ())
5050
5151 session .close ()
5252
@@ -101,14 +101,14 @@ def query_data():
101101 session = session_pool .get_session ()
102102
103103 print ("get data from table0" )
104- res = session .execute_query_statement ("select * from table0" )
105- while res .has_next ():
106- print (res .next ())
104+ with session .execute_query_statement ("select * from table0" ) as res :
105+ while res .has_next ():
106+ print (res .next ())
107107
108108 print ("get data from table1" )
109- res = session .execute_query_statement ("select * from table0" )
110- while res .has_next ():
111- print (res .next ())
109+ with session .execute_query_statement ("select * from table0" ) as res :
110+ while res .has_next ():
111+ print (res .next ())
112112
113113 session .close ()
114114
@@ -117,9 +117,9 @@ def delete_data():
117117 session = session_pool .get_session ()
118118 session .execute_non_query_statement ("drop database db1" )
119119 print ("data has been deleted. now the databases are:" )
120- res = session .execute_query_statement ("show databases" )
121- while res .has_next ():
122- print (res .next ())
120+ with session .execute_query_statement ("show databases" ) as res :
121+ while res .has_next ():
122+ print (res .next ())
123123 session .close ()
124124
125125
You can’t perform that action at this time.
0 commit comments