Skip to content

Commit

Permalink
add support for non-ascii character in string
Browse files Browse the repository at this point in the history
  • Loading branch information
chengbiao-jin committed Nov 5, 2024
1 parent 4392510 commit 7b2eee7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 7 additions & 2 deletions pyTigerGraph/pyTigerGraphLoading.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,13 @@ def runLoadingJobWithData(self, data: str, fileTag: str, jobName: str, sep: str
if eol is not None:
params["eol"] = eol

res = self._req("POST", self.restppUrl + "/ddl/" + self.graphname, params=params, data=data,
headers={"RESPONSE-LIMIT": str(sizeLimit), "GSQL-TIMEOUT": str(timeout)})
if isinstance(data, str):
data = data.encode("utf-8")
res = self._req("POST", self.restppUrl + "/ddl/" + self.graphname, params=params, data=data,
headers={"Content-Type": "application/x-www-form-urlencoded; Charset=utf-8", "RESPONSE-LIMIT": str(sizeLimit), "GSQL-TIMEOUT": str(timeout)})
else:
res = self._req("POST", self.restppUrl + "/ddl/" + self.graphname, params=params, data=data,
headers={"RESPONSE-LIMIT": str(sizeLimit), "GSQL-TIMEOUT": str(timeout)})

if logger.level == logging.DEBUG:
logger.debug("return: " + str(res))
Expand Down
9 changes: 7 additions & 2 deletions pyTigerGraph/pytgasync/pyTigerGraphLoading.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,13 @@ async def runLoadingJobWithData(self, data: str, fileTag: str, jobName: str, sep
if eol is not None:
params["eol"] = eol

res = await self._req("POST", self.restppUrl + "/ddl/" + self.graphname, params=params, data=data,
headers={"RESPONSE-LIMIT": str(sizeLimit), "GSQL-TIMEOUT": str(timeout)})
if isinstance(data, str):
data = data.encode("utf-8")
res = await self._req("POST", self.restppUrl + "/ddl/" + self.graphname, params=params, data=data,
headers={"Content-Type": "application/x-www-form-urlencoded; Charset=utf-8", "RESPONSE-LIMIT": str(sizeLimit), "GSQL-TIMEOUT": str(timeout)})
else:
res = await self._req("POST", self.restppUrl + "/ddl/" + self.graphname, params=params, data=data,
headers={"RESPONSE-LIMIT": str(sizeLimit), "GSQL-TIMEOUT": str(timeout)})

if logger.level == logging.DEBUG:
logger.debug("return: " + str(res))
Expand Down

0 comments on commit 7b2eee7

Please sign in to comment.