polygres-cli 0.1.0__py3-none-any.whl → 0.1.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
polygres_cli/cli.py CHANGED
@@ -45,7 +45,6 @@ UUID_LIKE_RE = re.compile(
45
45
  )
46
46
  SQL_IDENTIFIER_RE = re.compile(r"^[A-Za-z_][A-Za-z0-9_]*$")
47
47
  MIGRATION_NAME_RE = SQL_IDENTIFIER_RE
48
- MAX_CSV_UPLOAD_BYTES = 1024**3
49
48
  GRAPH_CONFIGURATION_KEYS = {
50
49
  "registered_tables",
51
50
  "registered_relationships",
@@ -992,19 +991,6 @@ def handle_text_configs_delete(ctx: Context, args: argparse.Namespace) -> int:
992
991
 
993
992
  def handle_import_csv(ctx: Context, args: argparse.Namespace) -> int:
994
993
  file_path = _readable_file(args.file)
995
- try:
996
- file_size = file_path.stat().st_size
997
- except OSError as exc:
998
- raise CliError(
999
- "VALIDATION_ERROR", f"Unable to read file: {file_path}", exit_code=USAGE
1000
- ) from exc
1001
- if file_size > MAX_CSV_UPLOAD_BYTES:
1002
- raise CliError(
1003
- "IMPORT_LIMIT_EXCEEDED",
1004
- "CSV file exceeds the 1 GiB local upload limit.",
1005
- exit_code=USAGE,
1006
- details={"limit_bytes": MAX_CSV_UPLOAD_BYTES, "file_size_bytes": file_size},
1007
- )
1008
994
  _validate_identifiers(args.schema, args.table)
1009
995
  preview_fields = {
1010
996
  "target_schema": args.schema,
@@ -1032,22 +1018,20 @@ def handle_import_csv(ctx: Context, args: argparse.Namespace) -> int:
1032
1018
  columns = preview_payload.get("columns")
1033
1019
  if not isinstance(columns, list):
1034
1020
  raise CliError("IMPORT_INVALID", "CSV preview response did not include columns.")
1035
- import_fields = {
1021
+ import_fields: dict[str, object] = {
1036
1022
  "target_schema": args.schema,
1037
1023
  "target_table": args.table,
1038
1024
  "mode": args.mode,
1039
1025
  "encoding": str(preview_payload.get("encoding", args.encoding)),
1040
1026
  "delimiter": str(preview_payload.get("delimiter", args.delimiter or "")),
1041
1027
  "quote_char": str(preview_payload.get("quote_char", args.quote_char or '"')),
1042
- "has_header": (
1043
- "true" if preview_payload.get("has_header", not args.no_header) else "false"
1044
- ),
1028
+ "has_header": bool(preview_payload.get("has_header", not args.no_header)),
1045
1029
  }
1046
1030
  effective_escape = preview_payload.get("escape_char", args.escape_char)
1047
1031
  if effective_escape is not None:
1048
1032
  import_fields["escape_char"] = str(effective_escape)
1049
- import_fields.update({"job_id": job_id, "columns": json.dumps(columns)})
1050
- started = ctx.client.start_csv_import(project_id, file_path, import_fields)
1033
+ import_fields.update({"job_id": job_id, "columns": columns})
1034
+ started = ctx.client.start_csv_import(project_id, import_fields)
1051
1035
  output = _import_output(started)
1052
1036
  if args.wait and output["import"].get("status") not in {"succeeded", "failed", "cancelled"}:
1053
1037
  import_id = output["import"].get("id")
@@ -1,6 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
- import json
3
+ import json as jsonlib
4
4
  import time
5
5
  from collections.abc import Callable
6
6
  from email.utils import parsedate_to_datetime
@@ -13,7 +13,7 @@ import httpx
13
13
  from polygres_cli.cli_errors import AUTH, UNAVAILABLE, CliError, api_error_from_response
14
14
  from polygres_cli.cli_secrets import redact_string
15
15
 
16
- VERSION = "0.1.0"
16
+ VERSION = "0.1.1"
17
17
  RETRY_STATUSES = {408, 429, 500, 502, 503, 504}
18
18
  HEAVY_REQUEST_TIMEOUT = 120.0
19
19
 
@@ -121,16 +121,13 @@ class CliControlPlaneClient:
121
121
  )
122
122
 
123
123
  def start_csv_import(
124
- self, project_id: str, file: Path, fields: dict[str, str]
124
+ self, project_id: str, fields: dict[str, Any]
125
125
  ) -> dict[str, Any]:
126
- with file.open("rb") as handle:
127
- return self._multipart(
128
- "POST",
129
- f"/projects/{project_id}/imports/csv",
130
- handle,
131
- file.name,
132
- fields,
133
- )
126
+ return self._post(
127
+ f"/projects/{project_id}/imports/csv",
128
+ fields,
129
+ timeout=HEAVY_REQUEST_TIMEOUT,
130
+ )
134
131
 
135
132
  def list_imports(self, project_id: str) -> dict[str, Any]:
136
133
  return self._get(f"/projects/{project_id}/imports")
@@ -292,10 +289,12 @@ class CliControlPlaneClient:
292
289
  try:
293
290
  request_kwargs: dict[str, Any] = {
294
291
  "headers": headers,
295
- "json": json,
296
292
  "data": data,
297
293
  "files": files,
298
294
  }
295
+ if json is not None:
296
+ headers["Content-Type"] = "application/json"
297
+ request_kwargs["content"] = jsonlib.dumps(json)
299
298
  request_timeout = timeout
300
299
  if remaining is not None:
301
300
  request_timeout = min(request_timeout or self._timeout, remaining)
@@ -392,7 +391,7 @@ def _json_payload(response: httpx.Response) -> dict[str, Any]:
392
391
  return {}
393
392
  try:
394
393
  payload = response.json()
395
- except json.JSONDecodeError:
394
+ except jsonlib.JSONDecodeError:
396
395
  return {}
397
396
  return payload if isinstance(payload, dict) else {}
398
397
 
@@ -16,6 +16,7 @@ LOCAL_DEPENDENCY = 9
16
16
 
17
17
  HTTP_EXIT_CODES = {
18
18
  400: USAGE,
19
+ 413: USAGE,
19
20
  401: AUTH,
20
21
  403: PERMISSION,
21
22
  404: NOT_FOUND,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: polygres-cli
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: Command-line interface for Polygres
5
5
  Project-URL: Homepage, https://polygres.com
6
6
  Project-URL: Documentation, https://docs.evokoa.com/polygres
@@ -0,0 +1,13 @@
1
+ polygres_cli/__init__.py,sha256=8Rp0AQILGzy9FXAxyB6P9xshB8dKxfYMjY8Iw0W7jlY,44
2
+ polygres_cli/cli.py,sha256=xRQBz8cAujfmTebwxRKNboTjyi_dN7do95BUM4vd5HI,73912
3
+ polygres_cli/cli_auth.py,sha256=2AXXNvBb3P1Nt96KVHwGAnLEo_IV4cfSkRx6tvRsVNU,3070
4
+ polygres_cli/cli_client.py,sha256=kOAIqln4yRxIiT7CiIWjF_Q92WyYaoYZux0AkjHh4rM,15636
5
+ polygres_cli/cli_config.py,sha256=cLxyXNhY07nrjxTsZt1ZH_L1H-HyRV6li4UIHMduR5o,2985
6
+ polygres_cli/cli_errors.py,sha256=SL-y4pMqFH0Lx-6MkElQymAQYW-xuDlCoCI4qki61ZQ,2349
7
+ polygres_cli/cli_output.py,sha256=8efqKYqKy4Uf1C_Uzkf1zVT-KVtdJ4SkCwvoise9wG0,1680
8
+ polygres_cli/cli_secrets.py,sha256=q_NiebEIHcc09BZxNw6sVyJ86fF3dYkzrhgmbfviz5M,1962
9
+ polygres_cli-0.1.1.dist-info/METADATA,sha256=jN4RvBenDzdQ8yqvKZqCSJYNBZZYiplesEBRv5JU2mI,3275
10
+ polygres_cli-0.1.1.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
11
+ polygres_cli-0.1.1.dist-info/entry_points.txt,sha256=j_tqtMTwo6q54nc_7ZAVArSHEbKAIcJXEr6VUptRcHE,51
12
+ polygres_cli-0.1.1.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
13
+ polygres_cli-0.1.1.dist-info/RECORD,,
@@ -1,13 +0,0 @@
1
- polygres_cli/__init__.py,sha256=8Rp0AQILGzy9FXAxyB6P9xshB8dKxfYMjY8Iw0W7jlY,44
2
- polygres_cli/cli.py,sha256=TlKF8Epnu7d8lU8D4FqDrdQrw9nh-BgSNxyhEbIO1X0,74489
3
- polygres_cli/cli_auth.py,sha256=2AXXNvBb3P1Nt96KVHwGAnLEo_IV4cfSkRx6tvRsVNU,3070
4
- polygres_cli/cli_client.py,sha256=vFFShCRcfu1ilQKieA0gl1mPSpJhWwau2OE-8O1GsBk,15591
5
- polygres_cli/cli_config.py,sha256=cLxyXNhY07nrjxTsZt1ZH_L1H-HyRV6li4UIHMduR5o,2985
6
- polygres_cli/cli_errors.py,sha256=llCplR7X9blAWHrWOXUntHS3KqCcToJOTSR-U1076Cw,2333
7
- polygres_cli/cli_output.py,sha256=8efqKYqKy4Uf1C_Uzkf1zVT-KVtdJ4SkCwvoise9wG0,1680
8
- polygres_cli/cli_secrets.py,sha256=q_NiebEIHcc09BZxNw6sVyJ86fF3dYkzrhgmbfviz5M,1962
9
- polygres_cli-0.1.0.dist-info/METADATA,sha256=TyUr6DSbSfMrHbp2wzCwM1auVL1AjDA53BtNFPcObk4,3275
10
- polygres_cli-0.1.0.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
11
- polygres_cli-0.1.0.dist-info/entry_points.txt,sha256=j_tqtMTwo6q54nc_7ZAVArSHEbKAIcJXEr6VUptRcHE,51
12
- polygres_cli-0.1.0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
13
- polygres_cli-0.1.0.dist-info/RECORD,,