execsql2 2.32.0__py3-none-any.whl → 2.33.0__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.
- execsql/metacommands/reference.py +10 -0
- execsql/metacommands/upsert.py +13 -0
- execsql/script/engine.py +5 -7
- execsql/script/executor.py +3 -1
- {execsql2-2.32.0.dist-info → execsql2-2.33.0.dist-info}/METADATA +2 -2
- {execsql2-2.32.0.dist-info → execsql2-2.33.0.dist-info}/RECORD +23 -23
- {execsql2-2.32.0.data → execsql2-2.33.0.data}/data/execsql2_extras/README.md +0 -0
- {execsql2-2.32.0.data → execsql2-2.33.0.data}/data/execsql2_extras/config_settings.sqlite +0 -0
- {execsql2-2.32.0.data → execsql2-2.33.0.data}/data/execsql2_extras/example_config_prompt.sql +0 -0
- {execsql2-2.32.0.data → execsql2-2.33.0.data}/data/execsql2_extras/make_config_db.sql +0 -0
- {execsql2-2.32.0.data → execsql2-2.33.0.data}/data/execsql2_extras/md_compare.sql +0 -0
- {execsql2-2.32.0.data → execsql2-2.33.0.data}/data/execsql2_extras/md_glossary.sql +0 -0
- {execsql2-2.32.0.data → execsql2-2.33.0.data}/data/execsql2_extras/md_upsert.sql +0 -0
- {execsql2-2.32.0.data → execsql2-2.33.0.data}/data/execsql2_extras/pg_compare.sql +0 -0
- {execsql2-2.32.0.data → execsql2-2.33.0.data}/data/execsql2_extras/pg_glossary.sql +0 -0
- {execsql2-2.32.0.data → execsql2-2.33.0.data}/data/execsql2_extras/script_template.sql +0 -0
- {execsql2-2.32.0.data → execsql2-2.33.0.data}/data/execsql2_extras/ss_compare.sql +0 -0
- {execsql2-2.32.0.data → execsql2-2.33.0.data}/data/execsql2_extras/ss_glossary.sql +0 -0
- {execsql2-2.32.0.data → execsql2-2.33.0.data}/data/execsql2_extras/ss_upsert.sql +0 -0
- {execsql2-2.32.0.dist-info → execsql2-2.33.0.dist-info}/WHEEL +0 -0
- {execsql2-2.32.0.dist-info → execsql2-2.33.0.dist-info}/entry_points.txt +0 -0
- {execsql2-2.32.0.dist-info → execsql2-2.33.0.dist-info}/licenses/LICENSE.txt +0 -0
- {execsql2-2.32.0.dist-info → execsql2-2.33.0.dist-info}/licenses/NOTICE +0 -0
|
@@ -1364,6 +1364,16 @@ _SYSTEM_VARIABLES: tuple[SystemVariable, ...] = (
|
|
|
1364
1364
|
"TRUE or FALSE: whether the changes were committed.",
|
|
1365
1365
|
"metacommands.md#pg_upsert",
|
|
1366
1366
|
),
|
|
1367
|
+
SystemVariable(
|
|
1368
|
+
"$PG_UPSERT_STATUS",
|
|
1369
|
+
"How the run ended: committed, dry_run, no_changes, qa_failed, cancelled or db_error.",
|
|
1370
|
+
"metacommands.md#pg_upsert",
|
|
1371
|
+
),
|
|
1372
|
+
SystemVariable(
|
|
1373
|
+
"$PG_UPSERT_ERROR",
|
|
1374
|
+
"The database error message when $PG_UPSERT_STATUS is db_error; otherwise empty.",
|
|
1375
|
+
"metacommands.md#pg_upsert",
|
|
1376
|
+
),
|
|
1367
1377
|
SystemVariable("$PG_UPSERT_STAGING_SCHEMA", "Staging schema name used.", "metacommands.md#pg_upsert"),
|
|
1368
1378
|
SystemVariable("$PG_UPSERT_BASE_SCHEMA", "Base schema name used.", "metacommands.md#pg_upsert"),
|
|
1369
1379
|
SystemVariable("$PG_UPSERT_TABLES", "Comma-separated list of table names processed.", "metacommands.md#pg_upsert"),
|
execsql/metacommands/upsert.py
CHANGED
|
@@ -185,6 +185,11 @@ def _set_subvars(result: Any) -> None:
|
|
|
185
185
|
sv("$PG_UPSERT_ROWS_UPDATED", str(result.total_updated))
|
|
186
186
|
sv("$PG_UPSERT_ROWS_INSERTED", str(result.total_inserted))
|
|
187
187
|
sv("$PG_UPSERT_COMMITTED", str(result.committed).upper())
|
|
188
|
+
# How the run ended: committed, dry_run, no_changes, qa_failed, cancelled
|
|
189
|
+
# or db_error. Empty for QA and CHECK, which do not run an upsert.
|
|
190
|
+
status = getattr(result, "status", None)
|
|
191
|
+
sv("$PG_UPSERT_STATUS", status.value if status is not None else "")
|
|
192
|
+
sv("$PG_UPSERT_ERROR", getattr(result, "error", None) or "")
|
|
188
193
|
sv("$PG_UPSERT_STAGING_SCHEMA", result.staging_schema)
|
|
189
194
|
sv("$PG_UPSERT_BASE_SCHEMA", result.base_schema)
|
|
190
195
|
sv("$PG_UPSERT_TABLES", ", ".join(t.table_name for t in result.tables))
|
|
@@ -426,6 +431,14 @@ def _handle_pg_upsert_errors(fn: Any, metacommandline: str | None) -> Any:
|
|
|
426
431
|
try:
|
|
427
432
|
return fn()
|
|
428
433
|
except UserCancelledError as exc:
|
|
434
|
+
# No result describes a run cancelled outside pg-upsert's own run();
|
|
435
|
+
# say what is known rather than leave an earlier run's values.
|
|
436
|
+
sv = _state.subvars.add_substitution
|
|
437
|
+
sv("$PG_UPSERT_STATUS", "cancelled")
|
|
438
|
+
sv("$PG_UPSERT_ERROR", "")
|
|
439
|
+
sv("$PG_UPSERT_COMMITTED", "FALSE")
|
|
440
|
+
sv("$PG_UPSERT_ROWS_UPDATED", "0")
|
|
441
|
+
sv("$PG_UPSERT_ROWS_INSERTED", "0")
|
|
429
442
|
raise ErrInfo(
|
|
430
443
|
"cmd",
|
|
431
444
|
command_text=metacommandline,
|
execsql/script/engine.py
CHANGED
|
@@ -108,6 +108,7 @@ class MetaCommand:
|
|
|
108
108
|
"""Match *cmd_str* against this entry's regex and, if it matches, invoke the handler.
|
|
109
109
|
|
|
110
110
|
Returns ``(True, return_value)`` on a match, ``(False, None)`` otherwise.
|
|
111
|
+
Raises :class:`ErrInfo` when the handler fails.
|
|
111
112
|
"""
|
|
112
113
|
# Runs the metacommand if the command string matches the regex.
|
|
113
114
|
m = self.rx.match(cmd_str.strip())
|
|
@@ -125,13 +126,10 @@ class MetaCommand:
|
|
|
125
126
|
er = ErrInfo("cmd", command_text=cmd_str, exception_msg=exception_desc())
|
|
126
127
|
er.__cause__ = exc
|
|
127
128
|
if er:
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
if self.set_error_flag:
|
|
133
|
-
_state.status.metacommand_error = True
|
|
134
|
-
return True, None
|
|
129
|
+
# The caller records the error ($LAST_ERROR, $ERROR_MESSAGE,
|
|
130
|
+
# the log, the error history) and halts or carries on.
|
|
131
|
+
if self.set_error_flag or _state.status.halt_on_metacommand_err:
|
|
132
|
+
raise er
|
|
135
133
|
else:
|
|
136
134
|
if self.set_error_flag:
|
|
137
135
|
_state.status.metacommand_error = False
|
execsql/script/executor.py
CHANGED
|
@@ -350,7 +350,9 @@ def _exec_metacommand(
|
|
|
350
350
|
if ctx.exec_log is not None:
|
|
351
351
|
ctx.exec_log.log_status_info(f"Metacommand error: {logged_error(e)}")
|
|
352
352
|
if status.halt_on_metacommand_err:
|
|
353
|
-
|
|
353
|
+
exit_now(1, e)
|
|
354
|
+
if (manifest := _manifest.current()) is not None:
|
|
355
|
+
manifest.record_metacommand(cmd, source, line_no, metacommandlist)
|
|
354
356
|
status.error_history.append((source, line_no, cmd, e.errmsg()))
|
|
355
357
|
return None
|
|
356
358
|
# No handler matched — truly unknown metacommand
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: execsql2
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.33.0
|
|
4
4
|
Summary: Runs a SQL script against a PostgreSQL, SQLite, MariaDB/MySQL, DuckDB, Firebird, MS-Access, MS-SQL-Server, or Oracle database, or an ODBC DSN. Provides metacommands to import and export data, copy data between databases, conditionally execute SQL and metacommands, and dynamically alter SQL and metacommands with substitution variables.
|
|
5
5
|
Project-URL: Homepage, https://execsql2.readthedocs.io/en/stable/
|
|
6
6
|
Project-URL: Repository, https://github.com/geocoug/execsql
|
|
@@ -441,7 +441,7 @@ execsql format --no-sql --in-place scripts/
|
|
|
441
441
|
```yaml
|
|
442
442
|
repos:
|
|
443
443
|
- repo: https://github.com/geocoug/execsql
|
|
444
|
-
rev: v2.
|
|
444
|
+
rev: v2.33.0
|
|
445
445
|
hooks:
|
|
446
446
|
- id: execsql-format
|
|
447
447
|
- id: execsql-lint
|
|
@@ -110,15 +110,15 @@ execsql/metacommands/io_fileops.py,sha256=CmdgfgTHFWlzsA5XzsHeu6B9OTncb0K8n9uEgS
|
|
|
110
110
|
execsql/metacommands/io_import.py,sha256=gJICeK1MOfG6D73I7m8zBCalvr_ZJzD-QBKOpKYeYXo,15684
|
|
111
111
|
execsql/metacommands/io_write.py,sha256=yXDkMbQ3haDARVATVUYZprakyJHSyk1NywdKkFLpQ14,12783
|
|
112
112
|
execsql/metacommands/prompt.py,sha256=PlXhtBYCembG_1SSCrwpQR10mGF3_jXodu4aCSHlSCM,37950
|
|
113
|
-
execsql/metacommands/reference.py,sha256=
|
|
113
|
+
execsql/metacommands/reference.py,sha256=qBsOfcu4pi3XQCL-ywusfbrTtpqwqrWUlVraj8tj5Co,54325
|
|
114
114
|
execsql/metacommands/script_ext.py,sha256=CsUbyq8QFPnnvfX_k7fPlYNvvRw1xLmAWER4Exo5pwc,3658
|
|
115
115
|
execsql/metacommands/system.py,sha256=6X2qmMpGUHDzyEluEotXt0Ks9jKQTpc2x0eoYNgN12M,7997
|
|
116
|
-
execsql/metacommands/upsert.py,sha256=
|
|
116
|
+
execsql/metacommands/upsert.py,sha256=hcYGonmh2sdijbqwNynn1-iajMnLp7x5vbRbtfjaf8c,21461
|
|
117
117
|
execsql/script/__init__.py,sha256=I7hVO6wm3iOocxRRGEcFHhjdtL1moKbUYLB-wKbjPdk,3267
|
|
118
118
|
execsql/script/ast.py,sha256=WqCpFxhxrT2IIGvbArTp3QS0BZryRZAb7IL4ri3I6xg,20591
|
|
119
119
|
execsql/script/control.py,sha256=WqLy-HLPqHG3vEzYpKMiIJsD7LpORjyQuUWzFzcGz4w,2327
|
|
120
|
-
execsql/script/engine.py,sha256=
|
|
121
|
-
execsql/script/executor.py,sha256=
|
|
120
|
+
execsql/script/engine.py,sha256=h1pUSXGqwJASLJizqzd9LBMn_U5Vuqc1UbaZk1xUinw,18468
|
|
121
|
+
execsql/script/executor.py,sha256=p6VWZeTMRPD_621I-CF4K2aaFaAbrY5I82hksrACFJQ,40999
|
|
122
122
|
execsql/script/parser.py,sha256=z73v6t6ZbPUKkRu-UOIL6q1cCRDeoRvG2aXXC8NpMvE,37162
|
|
123
123
|
execsql/script/variables.py,sha256=Tb01aHqOdWZbkgj-oW0ky3KWNy5N34XLD-Fm2eShYZM,17462
|
|
124
124
|
execsql/utils/__init__.py,sha256=0uR6JwVJQRX3vceByNBduCAf5dd5assKjeqJUWvpZoA,278
|
|
@@ -135,22 +135,22 @@ execsql/utils/paths.py,sha256=7IIHT6vqXTfs6Ltfrzm_I2ZV4pU8IuedOLkHo6a1_K8,1175
|
|
|
135
135
|
execsql/utils/regex.py,sha256=DGzPBl0Kt4--RbwPhoZI6Bm6N_CBUvI0DbqE4EF6qp8,3718
|
|
136
136
|
execsql/utils/strings.py,sha256=UQNjpRCEFa1UO6feU-M-9e24wWAvizs_iu_4fFusLxo,8516
|
|
137
137
|
execsql/utils/timer.py,sha256=eDYf5VzCNFk7oo90InJucUm3XcBdhYMogjZMqeg9xzc,1899
|
|
138
|
-
execsql2-2.
|
|
139
|
-
execsql2-2.
|
|
140
|
-
execsql2-2.
|
|
141
|
-
execsql2-2.
|
|
142
|
-
execsql2-2.
|
|
143
|
-
execsql2-2.
|
|
144
|
-
execsql2-2.
|
|
145
|
-
execsql2-2.
|
|
146
|
-
execsql2-2.
|
|
147
|
-
execsql2-2.
|
|
148
|
-
execsql2-2.
|
|
149
|
-
execsql2-2.
|
|
150
|
-
execsql2-2.
|
|
151
|
-
execsql2-2.
|
|
152
|
-
execsql2-2.
|
|
153
|
-
execsql2-2.
|
|
154
|
-
execsql2-2.
|
|
155
|
-
execsql2-2.
|
|
156
|
-
execsql2-2.
|
|
138
|
+
execsql2-2.33.0.data/data/execsql2_extras/README.md,sha256=6f5bWiBlKRn8s6GVrU423-HFrU1Jwbk2AabxraLu3AY,5398
|
|
139
|
+
execsql2-2.33.0.data/data/execsql2_extras/config_settings.sqlite,sha256=aY5cxR7Q7J6zJ4bC9lu5mHUrhy211Cq3MNKPQVCt02E,20480
|
|
140
|
+
execsql2-2.33.0.data/data/execsql2_extras/example_config_prompt.sql,sha256=2e8KzzVWhho8KxYVHETSVmZdhW7wodioDsqBLSL6m4s,7487
|
|
141
|
+
execsql2-2.33.0.data/data/execsql2_extras/make_config_db.sql,sha256=WwyC6dK-Eh5CAVppiBCDHqiI1_wEI9U95Ytpr4lsZkg,8726
|
|
142
|
+
execsql2-2.33.0.data/data/execsql2_extras/md_compare.sql,sha256=ARYEcOlxWLxfw-KCKDeJRdCqnuCb9PVwGaHtITR2sYU,26535
|
|
143
|
+
execsql2-2.33.0.data/data/execsql2_extras/md_glossary.sql,sha256=gu2PDTm295YvxR7cDp25Mf-xXHly0BvlMudoNOrep5Q,10931
|
|
144
|
+
execsql2-2.33.0.data/data/execsql2_extras/md_upsert.sql,sha256=YNUTFS6yB4bZXs-wRDn6dN8jL5wIumzZyE2uo5arIos,113407
|
|
145
|
+
execsql2-2.33.0.data/data/execsql2_extras/pg_compare.sql,sha256=WcupGxQoWtMwHVPuy42xCpP4gAV4Ttb1W-_hwh-3xb4,24529
|
|
146
|
+
execsql2-2.33.0.data/data/execsql2_extras/pg_glossary.sql,sha256=CfQz2HZj2nMvJfYfQrAmNYdx0uRrOIWsCXwVo5gKv_k,9953
|
|
147
|
+
execsql2-2.33.0.data/data/execsql2_extras/script_template.sql,sha256=s5i0HULxp49N2Cpd24iALleM_dBq5oLuN3Arx_4Z7-o,11140
|
|
148
|
+
execsql2-2.33.0.data/data/execsql2_extras/ss_compare.sql,sha256=PpU-vPyqqC1faBoo5zwVZlZHYKkT79QZisWVlk4o-ss,26415
|
|
149
|
+
execsql2-2.33.0.data/data/execsql2_extras/ss_glossary.sql,sha256=_oTiZHpadPXWrNs8VoRe9PZgX9XdK490NMVWVTVtjl4,13110
|
|
150
|
+
execsql2-2.33.0.data/data/execsql2_extras/ss_upsert.sql,sha256=Dvst877h4KHn8ayYF9EXI_OxqLQ89wyfcnGYYT4szro,118304
|
|
151
|
+
execsql2-2.33.0.dist-info/METADATA,sha256=knRnIG9a4tdioaIqDrEsatI7FJo3pzosRuQbWUsG3P4,26927
|
|
152
|
+
execsql2-2.33.0.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
|
|
153
|
+
execsql2-2.33.0.dist-info/entry_points.txt,sha256=jOf53-4IVGjEZeNYUOF1GGaiPNfVZcNKxP3vDFKEyMA,58
|
|
154
|
+
execsql2-2.33.0.dist-info/licenses/LICENSE.txt,sha256=LBdhuxejF8_bLCHZ2kWfmDXpDGUu914Gbd6_3JjCRe0,676
|
|
155
|
+
execsql2-2.33.0.dist-info/licenses/NOTICE,sha256=McYzgxYav3U1OaVsY4Su1sfBrfmplpRdA9b6-gCDQCg,342
|
|
156
|
+
execsql2-2.33.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
{execsql2-2.32.0.data → execsql2-2.33.0.data}/data/execsql2_extras/example_config_prompt.sql
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|