execsql2 2.39.1__py3-none-any.whl → 2.40.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/control.py +21 -23
- execsql/metacommands/script_ext.py +6 -2
- execsql/script/executor.py +7 -0
- execsql/script/parser.py +31 -0
- {execsql2-2.39.1.dist-info → execsql2-2.40.0.dist-info}/METADATA +2 -2
- {execsql2-2.39.1.dist-info → execsql2-2.40.0.dist-info}/RECORD +23 -23
- {execsql2-2.39.1.data → execsql2-2.40.0.data}/data/execsql2_extras/README.md +0 -0
- {execsql2-2.39.1.data → execsql2-2.40.0.data}/data/execsql2_extras/config_settings.sqlite +0 -0
- {execsql2-2.39.1.data → execsql2-2.40.0.data}/data/execsql2_extras/example_config_prompt.sql +0 -0
- {execsql2-2.39.1.data → execsql2-2.40.0.data}/data/execsql2_extras/make_config_db.sql +0 -0
- {execsql2-2.39.1.data → execsql2-2.40.0.data}/data/execsql2_extras/md_compare.sql +0 -0
- {execsql2-2.39.1.data → execsql2-2.40.0.data}/data/execsql2_extras/md_glossary.sql +0 -0
- {execsql2-2.39.1.data → execsql2-2.40.0.data}/data/execsql2_extras/md_upsert.sql +0 -0
- {execsql2-2.39.1.data → execsql2-2.40.0.data}/data/execsql2_extras/pg_compare.sql +0 -0
- {execsql2-2.39.1.data → execsql2-2.40.0.data}/data/execsql2_extras/pg_glossary.sql +0 -0
- {execsql2-2.39.1.data → execsql2-2.40.0.data}/data/execsql2_extras/script_template.sql +0 -0
- {execsql2-2.39.1.data → execsql2-2.40.0.data}/data/execsql2_extras/ss_compare.sql +0 -0
- {execsql2-2.39.1.data → execsql2-2.40.0.data}/data/execsql2_extras/ss_glossary.sql +0 -0
- {execsql2-2.39.1.data → execsql2-2.40.0.data}/data/execsql2_extras/ss_upsert.sql +0 -0
- {execsql2-2.39.1.dist-info → execsql2-2.40.0.dist-info}/WHEEL +0 -0
- {execsql2-2.39.1.dist-info → execsql2-2.40.0.dist-info}/entry_points.txt +0 -0
- {execsql2-2.39.1.dist-info → execsql2-2.40.0.dist-info}/licenses/LICENSE.txt +0 -0
- {execsql2-2.39.1.dist-info → execsql2-2.40.0.dist-info}/licenses/NOTICE +0 -0
execsql/metacommands/control.py
CHANGED
|
@@ -85,54 +85,52 @@ def x_assert(**kwargs: Any) -> None:
|
|
|
85
85
|
raise ErrInfo(type="assert", other_msg=message)
|
|
86
86
|
|
|
87
87
|
|
|
88
|
-
def
|
|
89
|
-
"""
|
|
90
|
-
|
|
91
|
-
These handlers stay registered in the dispatch table so ``execsql list
|
|
92
|
-
keywords`` and the VS Code grammar generator still see the keyword. The AST parser converts the source form (``IF`` / ``ENDIF`` /
|
|
93
|
-
``LOOP`` / ``BEGIN BATCH`` / ``BREAK`` / ``ELSE`` / ``ELSEIF`` / ``ANDIF``
|
|
94
|
-
/ ``ORIF``) into structural AST nodes that the executor walks directly —
|
|
95
|
-
none of these dispatch handlers fire for parsed scripts. Reaching one
|
|
96
|
-
means the AST parser failed to recognise the keyword, which is a bug.
|
|
97
|
-
"""
|
|
98
|
-
from execsql.exceptions import ErrInfo
|
|
88
|
+
def unsupported_block_error(name: str) -> ErrInfo:
|
|
89
|
+
"""Explain a block boundary supplied dynamically instead of in source.
|
|
99
90
|
|
|
91
|
+
The dispatch entries also keep structural keywords discoverable. They
|
|
92
|
+
can be reached by variable text or an inline IF containing a boundary;
|
|
93
|
+
this is an unsupported script form, not an internal parser failure.
|
|
94
|
+
"""
|
|
100
95
|
return ErrInfo(
|
|
101
96
|
type="cmd",
|
|
102
|
-
other_msg=
|
|
97
|
+
other_msg=(
|
|
98
|
+
f"{name} cannot run here; write the complete block directly in the script. "
|
|
99
|
+
"To append a block, define it with BEGIN SCRIPT and use EXTEND SCRIPT ... WITH SCRIPT."
|
|
100
|
+
),
|
|
103
101
|
)
|
|
104
102
|
|
|
105
103
|
|
|
106
104
|
def x_if(**kwargs: Any) -> None:
|
|
107
|
-
raise
|
|
105
|
+
raise unsupported_block_error("IF")
|
|
108
106
|
|
|
109
107
|
|
|
110
108
|
def x_if_orif(**kwargs: Any) -> None:
|
|
111
|
-
raise
|
|
109
|
+
raise unsupported_block_error("ORIF")
|
|
112
110
|
|
|
113
111
|
|
|
114
112
|
def x_if_andif(**kwargs: Any) -> None:
|
|
115
|
-
raise
|
|
113
|
+
raise unsupported_block_error("ANDIF")
|
|
116
114
|
|
|
117
115
|
|
|
118
116
|
def x_if_elseif(**kwargs: Any) -> None:
|
|
119
|
-
raise
|
|
117
|
+
raise unsupported_block_error("ELSEIF")
|
|
120
118
|
|
|
121
119
|
|
|
122
120
|
def x_if_else(**kwargs: Any) -> None:
|
|
123
|
-
raise
|
|
121
|
+
raise unsupported_block_error("ELSE")
|
|
124
122
|
|
|
125
123
|
|
|
126
124
|
def x_if_block(**kwargs: Any) -> None:
|
|
127
|
-
raise
|
|
125
|
+
raise unsupported_block_error("IF")
|
|
128
126
|
|
|
129
127
|
|
|
130
128
|
def x_if_end(**kwargs: Any) -> None:
|
|
131
|
-
raise
|
|
129
|
+
raise unsupported_block_error("ENDIF")
|
|
132
130
|
|
|
133
131
|
|
|
134
132
|
def x_loop(**kwargs: Any) -> None:
|
|
135
|
-
raise
|
|
133
|
+
raise unsupported_block_error("LOOP")
|
|
136
134
|
|
|
137
135
|
|
|
138
136
|
def x_halt(**kwargs: Any) -> None:
|
|
@@ -191,11 +189,11 @@ def x_metacommand_error_halt(**kwargs: Any) -> None:
|
|
|
191
189
|
|
|
192
190
|
|
|
193
191
|
def x_begin_batch(**kwargs: Any) -> None:
|
|
194
|
-
raise
|
|
192
|
+
raise unsupported_block_error("BEGIN BATCH")
|
|
195
193
|
|
|
196
194
|
|
|
197
195
|
def x_end_batch(**kwargs: Any) -> None:
|
|
198
|
-
raise
|
|
196
|
+
raise unsupported_block_error("END BATCH")
|
|
199
197
|
|
|
200
198
|
|
|
201
199
|
def x_rollback(**kwargs: Any) -> None:
|
|
@@ -204,7 +202,7 @@ def x_rollback(**kwargs: Any) -> None:
|
|
|
204
202
|
|
|
205
203
|
|
|
206
204
|
def x_break(**kwargs: Any) -> None:
|
|
207
|
-
raise
|
|
205
|
+
raise unsupported_block_error("BREAK")
|
|
208
206
|
|
|
209
207
|
|
|
210
208
|
def x_wait_until(**kwargs: Any) -> None:
|
|
@@ -69,12 +69,16 @@ def x_extendscript(**kwargs: Any) -> None:
|
|
|
69
69
|
|
|
70
70
|
def x_extendscript_metacommand(**kwargs: Any) -> None:
|
|
71
71
|
"""Append a single metacommand line to an existing SCRIPT body."""
|
|
72
|
-
from execsql.
|
|
72
|
+
from execsql.metacommands.control import unsupported_block_error
|
|
73
|
+
from execsql.script.parser import block_metacommand_name, metacommand_node
|
|
73
74
|
|
|
74
75
|
block = _get_ast_script(kwargs["script"])
|
|
76
|
+
command = kwargs["cmd"].strip()
|
|
77
|
+
if name := block_metacommand_name(command):
|
|
78
|
+
raise unsupported_block_error(name)
|
|
75
79
|
script_file, script_line_no = current_script_line()
|
|
76
80
|
span = _new_span(script_file, script_line_no or 0)
|
|
77
|
-
block.body.append(metacommand_node(
|
|
81
|
+
block.body.append(metacommand_node(command, span))
|
|
78
82
|
|
|
79
83
|
|
|
80
84
|
def x_extendscript_sql(**kwargs: Any) -> None:
|
execsql/script/executor.py
CHANGED
|
@@ -496,6 +496,13 @@ def _exec_metacommand(
|
|
|
496
496
|
if (manifest := _manifest.current()) is not None:
|
|
497
497
|
manifest.record_metacommand(cmd, source, line_no, metacommandlist)
|
|
498
498
|
return result
|
|
499
|
+
# Variable-supplied boundaries without a dispatch entry (END LOOP,
|
|
500
|
+
# SCRIPT and SQL) follow the same error policy as IF and BEGIN BATCH.
|
|
501
|
+
from execsql.metacommands.control import unsupported_block_error
|
|
502
|
+
from execsql.script.parser import block_metacommand_name
|
|
503
|
+
|
|
504
|
+
if name := block_metacommand_name(cmd):
|
|
505
|
+
raise unsupported_block_error(name)
|
|
499
506
|
except _ScriptExecutionError as failure:
|
|
500
507
|
# The called script already owns its error policy; do not apply the prompt's again.
|
|
501
508
|
raise failure.error from failure.error.__cause__
|
execsql/script/parser.py
CHANGED
|
@@ -193,6 +193,37 @@ def substitute_directive(node: IncludeDirective, substitute: Callable[[str], str
|
|
|
193
193
|
return replace(node, target=strip_quotes(values["target"].strip()), command=command)
|
|
194
194
|
|
|
195
195
|
|
|
196
|
+
def block_metacommand_name(command: str) -> str | None:
|
|
197
|
+
"""Name a block boundary that needs parsing with the surrounding source.
|
|
198
|
+
|
|
199
|
+
Reuse the source parser's patterns, including boundaries nested in an
|
|
200
|
+
inline IF. This only detects unsupported dynamic boundaries; it never
|
|
201
|
+
reclassifies variable text into executable control flow.
|
|
202
|
+
"""
|
|
203
|
+
inline = _IF_INLINE_RX.match(command)
|
|
204
|
+
if inline:
|
|
205
|
+
return block_metacommand_name(inline.group("cmd").strip())
|
|
206
|
+
for pattern, name in (
|
|
207
|
+
(_IF_BLOCK_RX, "IF"),
|
|
208
|
+
(_ELSEIF_RX, "ELSEIF"),
|
|
209
|
+
(_ANDIF_RX, "ANDIF"),
|
|
210
|
+
(_ORIF_RX, "ORIF"),
|
|
211
|
+
(_ELSE_RX, "ELSE"),
|
|
212
|
+
(_ENDIF_RX, "ENDIF"),
|
|
213
|
+
(_LOOP_RX, "LOOP"),
|
|
214
|
+
(_ENDLOOP_RX, "END LOOP"),
|
|
215
|
+
(_BEGIN_BATCH_RX, "BEGIN BATCH"),
|
|
216
|
+
(_END_BATCH_RX, "END BATCH"),
|
|
217
|
+
(_BEGIN_SCRIPT_RX, "BEGIN SCRIPT"),
|
|
218
|
+
(_END_SCRIPT_RX, "END SCRIPT"),
|
|
219
|
+
(_BEGIN_SQL_RX, "BEGIN SQL"),
|
|
220
|
+
(_END_SQL_RX, "END SQL"),
|
|
221
|
+
):
|
|
222
|
+
if pattern.match(command):
|
|
223
|
+
return name
|
|
224
|
+
return None
|
|
225
|
+
|
|
226
|
+
|
|
196
227
|
def metacommand_node(command: str, span: SourceSpan) -> IfBlock | IncludeDirective | MetaCommandStatement:
|
|
197
228
|
"""The node for a metacommand that opens or closes no block, however it is reached.
|
|
198
229
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: execsql2
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.40.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
|
|
@@ -351,7 +351,7 @@ execsql format --no-sql --in-place scripts/
|
|
|
351
351
|
```yaml
|
|
352
352
|
repos:
|
|
353
353
|
- repo: https://github.com/geocoug/execsql
|
|
354
|
-
rev: v2.
|
|
354
|
+
rev: v2.40.0
|
|
355
355
|
hooks:
|
|
356
356
|
- id: execsql-format
|
|
357
357
|
- id: execsql-lint
|
|
@@ -100,7 +100,7 @@ execsql/lsp/server.py,sha256=gTjk1agZbygdbcowa3jkL45WJ37sxhJ58oiLB7BM6Bw,19893
|
|
|
100
100
|
execsql/metacommands/__init__.py,sha256=aMf-3IRjMpNFSUI-IMAcvL-kXZHq5qF6W_p3UawdQwM,13115
|
|
101
101
|
execsql/metacommands/conditions.py,sha256=0mZWv9P8EdEjiJ1K0yDX1kxe44GSlR37W8bCI_1Ac6k,29966
|
|
102
102
|
execsql/metacommands/connect.py,sha256=Hi5Jp0sg3oDqxVvkWhkv6ErVEgofKhC_mg44CXOPHU0,16351
|
|
103
|
-
execsql/metacommands/control.py,sha256=
|
|
103
|
+
execsql/metacommands/control.py,sha256=rtPlUE0m3oW6xM-woEUFkgxSGE-k1uelKboDdvQ3llU,9907
|
|
104
104
|
execsql/metacommands/data.py,sha256=K0QHV3Ylm7aGVXnb6rsJEgWvs77QeTl_5u5U_iqZWEo,12749
|
|
105
105
|
execsql/metacommands/debug.py,sha256=mKRT7uLwnw34Xl46fNDI_zH4MsPpZyihoLlonapbXuU,12981
|
|
106
106
|
execsql/metacommands/dispatch.py,sha256=d1naMWvDLoFR-qYnMI0usmonRCdNF7zF5vcl9yBb98I,87981
|
|
@@ -112,15 +112,15 @@ execsql/metacommands/io_import.py,sha256=bjn-YN6UdKxMyIYG2u_ztLG8IudihXIYBgvNOxt
|
|
|
112
112
|
execsql/metacommands/io_write.py,sha256=EGqiaP6-YDTqC2r7s19PlHRnVBJVM9BuU_ArqWHGxSo,12555
|
|
113
113
|
execsql/metacommands/prompt.py,sha256=2UVzWGw0k9vJACBcLMYG5ar0wqbsLqhcCAbE2HTJR_E,40786
|
|
114
114
|
execsql/metacommands/reference.py,sha256=M8T_MSACfzfLg3AshFZR4IfWsjEsRH8GsZ5pXNsGoPU,54688
|
|
115
|
-
execsql/metacommands/script_ext.py,sha256=
|
|
115
|
+
execsql/metacommands/script_ext.py,sha256=SAYpALCGWuveAq3VcN0XLRkt1aF_eylrbgF8CYVrSSI,4124
|
|
116
116
|
execsql/metacommands/system.py,sha256=rZ69MxtnoFVY_VBBj_1Q6M1G_HMA1KqUES7cdOGpE5Q,8421
|
|
117
117
|
execsql/metacommands/upsert.py,sha256=hcYGonmh2sdijbqwNynn1-iajMnLp7x5vbRbtfjaf8c,21461
|
|
118
118
|
execsql/script/__init__.py,sha256=I7hVO6wm3iOocxRRGEcFHhjdtL1moKbUYLB-wKbjPdk,3267
|
|
119
119
|
execsql/script/ast.py,sha256=KexrVh6dE4nHCB5CbC9odiPdyWw4rnUqD8bOsYdyNXg,21417
|
|
120
120
|
execsql/script/control.py,sha256=GF-IpfEwfsz306087Huq9hx4C84SVo-r7kew_e5QsLg,5170
|
|
121
121
|
execsql/script/engine.py,sha256=m40bLnFnWz8Uib4dfXbOv4JvKsIZ9nkFiFUNEfTd2Fc,18486
|
|
122
|
-
execsql/script/executor.py,sha256=
|
|
123
|
-
execsql/script/parser.py,sha256=
|
|
122
|
+
execsql/script/executor.py,sha256=vdAVQFw80EnegvFQNgiuj1DADfJ0PdzJzQ2RumZNsv0,54025
|
|
123
|
+
execsql/script/parser.py,sha256=v5C67-FP09wWGRdyxwZdljh_SwxO3zql3LN0IhxZCN4,40758
|
|
124
124
|
execsql/script/preparation.py,sha256=yxZN6L2_pQR1rJ_jhoFUpaOYEw5bQVsu2HawDZ_rhRY,1626
|
|
125
125
|
execsql/script/variables.py,sha256=XHRnViFp0zPy-skGpYbpckkYAcczqpw1lqTVLR9eZvo,17735
|
|
126
126
|
execsql/utils/__init__.py,sha256=0uR6JwVJQRX3vceByNBduCAf5dd5assKjeqJUWvpZoA,278
|
|
@@ -139,22 +139,22 @@ execsql/utils/sigterm.py,sha256=_oK-Hj8vHiKTgR04mNud7BMX90Fb1TDHb9eT7f-auAI,5842
|
|
|
139
139
|
execsql/utils/spreadsheet.py,sha256=XlFfanhLivQb-UlMrGQpUYtA6mjWXZrlpFom8QsidJM,2785
|
|
140
140
|
execsql/utils/strings.py,sha256=gHmR3BDl6YkHDHt2xaTN-KEhrhxNl7838V4lzrohLRU,8657
|
|
141
141
|
execsql/utils/timer.py,sha256=eDYf5VzCNFk7oo90InJucUm3XcBdhYMogjZMqeg9xzc,1899
|
|
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.
|
|
157
|
-
execsql2-2.
|
|
158
|
-
execsql2-2.
|
|
159
|
-
execsql2-2.
|
|
160
|
-
execsql2-2.
|
|
142
|
+
execsql2-2.40.0.data/data/execsql2_extras/README.md,sha256=W3lNyuOpx73eiyGl6DlqgO0OiznbzPUg65xMNmq1mQQ,5756
|
|
143
|
+
execsql2-2.40.0.data/data/execsql2_extras/config_settings.sqlite,sha256=aY5cxR7Q7J6zJ4bC9lu5mHUrhy211Cq3MNKPQVCt02E,20480
|
|
144
|
+
execsql2-2.40.0.data/data/execsql2_extras/example_config_prompt.sql,sha256=ckoBxBNyuff06R45qClCRmdZa_uxR8gF6nubrZEASlQ,7486
|
|
145
|
+
execsql2-2.40.0.data/data/execsql2_extras/make_config_db.sql,sha256=WwyC6dK-Eh5CAVppiBCDHqiI1_wEI9U95Ytpr4lsZkg,8726
|
|
146
|
+
execsql2-2.40.0.data/data/execsql2_extras/md_compare.sql,sha256=ARYEcOlxWLxfw-KCKDeJRdCqnuCb9PVwGaHtITR2sYU,26535
|
|
147
|
+
execsql2-2.40.0.data/data/execsql2_extras/md_glossary.sql,sha256=gu2PDTm295YvxR7cDp25Mf-xXHly0BvlMudoNOrep5Q,10931
|
|
148
|
+
execsql2-2.40.0.data/data/execsql2_extras/md_upsert.sql,sha256=YNUTFS6yB4bZXs-wRDn6dN8jL5wIumzZyE2uo5arIos,113407
|
|
149
|
+
execsql2-2.40.0.data/data/execsql2_extras/pg_compare.sql,sha256=WcupGxQoWtMwHVPuy42xCpP4gAV4Ttb1W-_hwh-3xb4,24529
|
|
150
|
+
execsql2-2.40.0.data/data/execsql2_extras/pg_glossary.sql,sha256=CfQz2HZj2nMvJfYfQrAmNYdx0uRrOIWsCXwVo5gKv_k,9953
|
|
151
|
+
execsql2-2.40.0.data/data/execsql2_extras/script_template.sql,sha256=s5i0HULxp49N2Cpd24iALleM_dBq5oLuN3Arx_4Z7-o,11140
|
|
152
|
+
execsql2-2.40.0.data/data/execsql2_extras/ss_compare.sql,sha256=PpU-vPyqqC1faBoo5zwVZlZHYKkT79QZisWVlk4o-ss,26415
|
|
153
|
+
execsql2-2.40.0.data/data/execsql2_extras/ss_glossary.sql,sha256=_oTiZHpadPXWrNs8VoRe9PZgX9XdK490NMVWVTVtjl4,13110
|
|
154
|
+
execsql2-2.40.0.data/data/execsql2_extras/ss_upsert.sql,sha256=Dvst877h4KHn8ayYF9EXI_OxqLQ89wyfcnGYYT4szro,118304
|
|
155
|
+
execsql2-2.40.0.dist-info/METADATA,sha256=6faMw2-Rx3CvKskKvQwAKPpmkwpHdrwFvS8l1RZLjoc,24189
|
|
156
|
+
execsql2-2.40.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
157
|
+
execsql2-2.40.0.dist-info/entry_points.txt,sha256=jOf53-4IVGjEZeNYUOF1GGaiPNfVZcNKxP3vDFKEyMA,58
|
|
158
|
+
execsql2-2.40.0.dist-info/licenses/LICENSE.txt,sha256=LBdhuxejF8_bLCHZ2kWfmDXpDGUu914Gbd6_3JjCRe0,676
|
|
159
|
+
execsql2-2.40.0.dist-info/licenses/NOTICE,sha256=McYzgxYav3U1OaVsY4Su1sfBrfmplpRdA9b6-gCDQCg,342
|
|
160
|
+
execsql2-2.40.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
{execsql2-2.39.1.data → execsql2-2.40.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
|