Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Commit

Permalink
Rename chunk_base64 as attribute name
Browse files Browse the repository at this point in the history
  • Loading branch information
Xuebin Su committed Sep 19, 2023
1 parent 3d99a52 commit 4061bce
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions greenplumpython/experimental/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,22 @@ def _from_files(_, files: list[str], parser: NormalFunction, db: gp.Database) ->
tmp_archive.add(pathlib.Path(file_path))
with psycopg2.connect(db._conn.dsn, options="-c gp_session_role=utility") as util_conn:
with util_conn.cursor() as cursor:
cursor.execute(f"CREATE TEMP TABLE {tmp_archive_name} (id serial, chunk_base64 text);")
cursor.execute(f"CREATE TEMP TABLE {tmp_archive_name} (id serial, text_base64 text);")
with open(tmp_archive_path, "rb") as tmp_archive:
while True:
chunk = tmp_archive.read(_CHUNK_SIZE)
if len(chunk) == 0:
break
chunk_base64 = base64.b64encode(chunk)
cursor.copy_expert(
f"COPY {tmp_archive_name} (chunk_base64) FROM STDIN",
f"COPY {tmp_archive_name} (text_base64) FROM STDIN",
io.BytesIO(chunk_base64),
)
util_conn.commit()
cursor.execute(_dump_file_chunk._serialize(db)) # type: ignore reportUnknownArgumentType
cursor.execute(
f"""
SELECT {_dump_file_chunk._qualified_name_str}('{tmp_archive_name}', chunk_base64)
SELECT {_dump_file_chunk._qualified_name_str}('{tmp_archive_name}', text_base64)
FROM "{tmp_archive_name}"
ORDER BY id;
"""
Expand Down

0 comments on commit 4061bce

Please sign in to comment.