Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Commit a034ad8

Browse files
committed
fix session state update
1 parent dec102e commit a034ad8

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

databend_py/connection.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,9 @@ def query(self, statement):
223223
log.logger.debug(f"http headers {self.make_headers()}")
224224
try:
225225
resp_dict = self.do_query(url, query_sql)
226-
self.client_session = resp_dict.get("session", self.default_session())
226+
new_session_state = resp_dict.get("session", self.default_session())
227+
if new_session_state:
228+
self.client_session = new_session_state
227229
if self.additional_headers:
228230
self.additional_headers.update(
229231
{XDatabendQueryIDHeader: resp_dict.get(QueryID)}
@@ -286,15 +288,15 @@ def query_with_session(self, statement):
286288
response_list.append(response)
287289
start_time = time.time()
288290
time_limit = 12
289-
session = response.get("session", self.default_session())
291+
session = response.get("session")
290292
if session:
291293
self.client_session = session
292294
while response["next_uri"] is not None:
293295
resp = self.next_page(response["next_uri"])
294296
response = json.loads(resp.content)
295297
log.logger.debug(f"Sql in progress, fetch next_uri content: {response}")
296298
self.check_error(response)
297-
session = response.get("session", self.default_session())
299+
session = response.get("session")
298300
if session:
299301
self.client_session = session
300302
response_list.append(response)

0 commit comments

Comments
 (0)