Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions iotdb-client/client-py/session_pool_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ def query_data():
session = session_pool.get_session()

print("get data from root.test.d0")
res = session.execute_query_statement("select * from root.test.d0")
while res.has_next():
print(res.next())
with session.execute_query_statement("select * from root.test.d0") as res:
while res.has_next():
print(res.next())

print("get data from root.test.d1")
res = session.execute_query_statement("select * from root.test.d1")
while res.has_next():
print(res.next())
with session.execute_query_statement("select * from root.test.d1") as res:
while res.has_next():
print(res.next())

session_pool.put_back(session)

Expand All @@ -105,9 +105,9 @@ def delete_data():
session = session_pool.get_session()
session.delete_storage_group(STORAGE_GROUP_NAME)
print("data has been deleted. now the devices are:")
res = session.execute_statement("show devices root.test.**")
while res.has_next():
print(res.next())
with session.execute_statement("show devices root.test.**") as res:
while res.has_next():
print(res.next())
session_pool.put_back(session)


Expand Down
24 changes: 12 additions & 12 deletions iotdb-client/client-py/table_model_session_pool_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ def prepare_data():

print("now the tables are:")
# show result
res = session.execute_query_statement("SHOW TABLES")
while res.has_next():
print(res.next())
with session.execute_query_statement("SHOW TABLES") as res:
while res.has_next():
print(res.next())

session.close()

Expand Down Expand Up @@ -101,14 +101,14 @@ def query_data():
session = session_pool.get_session()

print("get data from table0")
res = session.execute_query_statement("select * from table0")
while res.has_next():
print(res.next())
with session.execute_query_statement("select * from table0") as res:
while res.has_next():
print(res.next())

print("get data from table1")
res = session.execute_query_statement("select * from table0")
while res.has_next():
print(res.next())
with session.execute_query_statement("select * from table0") as res:
while res.has_next():
print(res.next())

session.close()

Expand All @@ -117,9 +117,9 @@ def delete_data():
session = session_pool.get_session()
session.execute_non_query_statement("drop database db1")
print("data has been deleted. now the databases are:")
res = session.execute_query_statement("show databases")
while res.has_next():
print(res.next())
with session.execute_query_statement("show databases") as res:
while res.has_next():
print(res.next())
session.close()


Expand Down
Loading