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

Commit 5b7d9df

Browse files
authored
Merge branch 'main' into feat/add-txn-test
2 parents b9cff02 + 6598081 commit 5b7d9df

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

databend_py/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.5.5
1+
0.5.6

databend_py/connection.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def query(self, statement):
165165
resp_dict = self.do_query(url, query_sql)
166166
self.client_session = resp_dict.get("session", self.default_session())
167167
self.additional_headers = {XDatabendQueryIDHeader: resp_dict.get(QueryID)}
168-
return resp_dict
168+
return self.wait_until_has_schema(resp_dict)
169169
except Exception as err:
170170
log.logger.error(
171171
f"http error on {url}, SQL: {statement} error msg:{str(err)}"
@@ -182,6 +182,19 @@ def format_url(self):
182182
def reset_session(self):
183183
self.client_session = dict()
184184

185+
def wait_until_has_schema(self, raw_data_dict):
186+
resp_schema = raw_data_dict.get("schema")
187+
while resp_schema is not None and len(resp_schema) == 0:
188+
if raw_data_dict['next_uri'] is None:
189+
break
190+
resp = self.next_page(raw_data_dict['next_uri'])
191+
resp_dict = json.loads(resp.content)
192+
raw_data_dict = resp_dict
193+
resp_schema = raw_data_dict.get("schema")
194+
if resp_schema is not None and (len(resp_schema) != 0 or len(raw_data_dict.get("data")) != 0):
195+
break
196+
return raw_data_dict
197+
185198
def next_page(self, next_uri):
186199
url = "{}://{}:{}{}".format(self.schema, self.host, self.port, next_uri)
187200
return self.requests_session.get(url=url, headers=self.make_headers(), cookies=self.cookies)

0 commit comments

Comments
 (0)