execsql2 2.16.3__py3-none-any.whl → 2.16.5__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/debug/repl.py +23 -3
- execsql/script/executor.py +34 -0
- {execsql2-2.16.3.dist-info → execsql2-2.16.5.dist-info}/METADATA +1 -1
- {execsql2-2.16.3.dist-info → execsql2-2.16.5.dist-info}/RECORD +23 -23
- {execsql2-2.16.3.data → execsql2-2.16.5.data}/data/execsql2_extras/README.md +0 -0
- {execsql2-2.16.3.data → execsql2-2.16.5.data}/data/execsql2_extras/config_settings.sqlite +0 -0
- {execsql2-2.16.3.data → execsql2-2.16.5.data}/data/execsql2_extras/example_config_prompt.sql +0 -0
- {execsql2-2.16.3.data → execsql2-2.16.5.data}/data/execsql2_extras/execsql.conf +0 -0
- {execsql2-2.16.3.data → execsql2-2.16.5.data}/data/execsql2_extras/make_config_db.sql +0 -0
- {execsql2-2.16.3.data → execsql2-2.16.5.data}/data/execsql2_extras/md_compare.sql +0 -0
- {execsql2-2.16.3.data → execsql2-2.16.5.data}/data/execsql2_extras/md_glossary.sql +0 -0
- {execsql2-2.16.3.data → execsql2-2.16.5.data}/data/execsql2_extras/md_upsert.sql +0 -0
- {execsql2-2.16.3.data → execsql2-2.16.5.data}/data/execsql2_extras/pg_compare.sql +0 -0
- {execsql2-2.16.3.data → execsql2-2.16.5.data}/data/execsql2_extras/pg_glossary.sql +0 -0
- {execsql2-2.16.3.data → execsql2-2.16.5.data}/data/execsql2_extras/pg_upsert.sql +0 -0
- {execsql2-2.16.3.data → execsql2-2.16.5.data}/data/execsql2_extras/script_template.sql +0 -0
- {execsql2-2.16.3.data → execsql2-2.16.5.data}/data/execsql2_extras/ss_compare.sql +0 -0
- {execsql2-2.16.3.data → execsql2-2.16.5.data}/data/execsql2_extras/ss_glossary.sql +0 -0
- {execsql2-2.16.3.data → execsql2-2.16.5.data}/data/execsql2_extras/ss_upsert.sql +0 -0
- {execsql2-2.16.3.dist-info → execsql2-2.16.5.dist-info}/WHEEL +0 -0
- {execsql2-2.16.3.dist-info → execsql2-2.16.5.dist-info}/entry_points.txt +0 -0
- {execsql2-2.16.3.dist-info → execsql2-2.16.5.dist-info}/licenses/LICENSE.txt +0 -0
- {execsql2-2.16.3.dist-info → execsql2-2.16.5.dist-info}/licenses/NOTICE +0 -0
execsql/debug/repl.py
CHANGED
|
@@ -336,7 +336,13 @@ def _print_all_vars(*, include_env: bool = False) -> None:
|
|
|
336
336
|
if subvars is None:
|
|
337
337
|
_write(" (no substitution variables defined)\n\n")
|
|
338
338
|
return
|
|
339
|
-
items = subvars.substitutions # list of (name, value) tuples
|
|
339
|
+
items = list(subvars.substitutions) # list of (name, value) tuples
|
|
340
|
+
# Include ~local and #param variables from the current stack frame.
|
|
341
|
+
if _state.commandliststack:
|
|
342
|
+
frame = _state.commandliststack[-1]
|
|
343
|
+
items.extend(frame.localvars.substitutions)
|
|
344
|
+
if frame.paramvals is not None:
|
|
345
|
+
items.extend(frame.paramvals.substitutions)
|
|
340
346
|
if not items:
|
|
341
347
|
_write(" (no substitution variables defined)\n\n")
|
|
342
348
|
return
|
|
@@ -389,6 +395,7 @@ def _print_var(varname: str) -> None:
|
|
|
389
395
|
"""Print the value of a single substitution variable.
|
|
390
396
|
|
|
391
397
|
Tries the name as typed, then with the sigil prefix stripped.
|
|
398
|
+
Checks both global subvars and the current stack frame's local/param vars.
|
|
392
399
|
"""
|
|
393
400
|
subvars = _state.subvars
|
|
394
401
|
if subvars is None:
|
|
@@ -400,6 +407,12 @@ def _print_var(varname: str) -> None:
|
|
|
400
407
|
value = subvars.varvalue(varname)
|
|
401
408
|
if value is None and len(varname) > 1 and varname[0] in "$&@#~":
|
|
402
409
|
value = subvars.varvalue(varname[1:])
|
|
410
|
+
# Check stack frame for ~local and #param variables.
|
|
411
|
+
if value is None and _state.commandliststack:
|
|
412
|
+
frame = _state.commandliststack[-1]
|
|
413
|
+
value = frame.localvars.varvalue(varname)
|
|
414
|
+
if value is None and frame.paramvals is not None:
|
|
415
|
+
value = frame.paramvals.varvalue(varname)
|
|
403
416
|
if value is None:
|
|
404
417
|
_write(f" {_c(_CYAN, varname)}: {_c(_DIM, '(undefined)')}\n")
|
|
405
418
|
else:
|
|
@@ -477,13 +490,20 @@ def _enable_step_mode() -> None:
|
|
|
477
490
|
def _set_var(varname: str, value: str) -> None:
|
|
478
491
|
"""Set or update a substitution variable in the current session.
|
|
479
492
|
|
|
493
|
+
Routes ~local variables to the current stack frame's localvars (matching
|
|
494
|
+
the behavior of ``x_sub`` / ``get_subvarset``). All other variables go
|
|
495
|
+
to the global subvars pool.
|
|
496
|
+
|
|
480
497
|
Args:
|
|
481
|
-
varname: The variable name (
|
|
498
|
+
varname: The variable name (with optional sigil prefix).
|
|
482
499
|
value: The value to assign to the variable.
|
|
483
500
|
"""
|
|
484
501
|
subvars = _state.subvars
|
|
485
502
|
if subvars is None:
|
|
486
503
|
_write(" Error: substitution variables are not initialised.\n")
|
|
487
504
|
return
|
|
488
|
-
|
|
505
|
+
if varname.startswith("~") and _state.commandliststack:
|
|
506
|
+
_state.commandliststack[-1].localvars.add_substitution(varname, value)
|
|
507
|
+
else:
|
|
508
|
+
subvars.add_substitution(varname, value)
|
|
489
509
|
_write(f" {_c(_CYAN, varname)} {_c(_DIM, '=')} {value}\n")
|
execsql/script/executor.py
CHANGED
|
@@ -448,6 +448,33 @@ def _execute_batch(
|
|
|
448
448
|
ctx.status.batch.end_batch()
|
|
449
449
|
|
|
450
450
|
|
|
451
|
+
def _pre_register_scripts(ctx: RuntimeContext, nodes: list[Node]) -> None:
|
|
452
|
+
"""Pre-scan AST nodes and register all ScriptBlock definitions.
|
|
453
|
+
|
|
454
|
+
The legacy engine used a two-pass approach — parse first (registering all
|
|
455
|
+
BEGIN SCRIPT blocks), then execute. The AST executor walks the tree in a
|
|
456
|
+
single pass, so forward references (EXECUTE SCRIPT before BEGIN SCRIPT)
|
|
457
|
+
would fail. This pre-scan restores compatibility by registering all script
|
|
458
|
+
blocks before execution begins.
|
|
459
|
+
|
|
460
|
+
Only scans the top level and inside IF/ELSE blocks — SCRIPT blocks inside
|
|
461
|
+
LOOPs or other SCRIPTs are not pre-registered (matching legacy behavior
|
|
462
|
+
where nested definitions weren't visible until the enclosing block ran).
|
|
463
|
+
"""
|
|
464
|
+
for node in nodes:
|
|
465
|
+
if isinstance(node, ScriptBlock):
|
|
466
|
+
_register_script_block(ctx, node)
|
|
467
|
+
elif isinstance(node, IfBlock):
|
|
468
|
+
# Scripts defined inside IF branches should be registered too,
|
|
469
|
+
# since the legacy parser registered them unconditionally at
|
|
470
|
+
# parse time regardless of the IF condition.
|
|
471
|
+
_pre_register_scripts(ctx, node.body)
|
|
472
|
+
for clause in node.elseif_clauses:
|
|
473
|
+
_pre_register_scripts(ctx, clause.body)
|
|
474
|
+
if node.else_body:
|
|
475
|
+
_pre_register_scripts(ctx, node.else_body)
|
|
476
|
+
|
|
477
|
+
|
|
451
478
|
def _register_script_block(ctx: RuntimeContext, node: ScriptBlock) -> None:
|
|
452
479
|
"""Register a named SCRIPT block.
|
|
453
480
|
|
|
@@ -799,6 +826,9 @@ def _execute_include_native(
|
|
|
799
826
|
encoding = ctx.conf.script_encoding if ctx.conf else "utf-8"
|
|
800
827
|
included_tree = parse_script(target, encoding=encoding)
|
|
801
828
|
|
|
829
|
+
# Pre-register SCRIPT blocks in the included file so forward references work.
|
|
830
|
+
_pre_register_scripts(ctx, included_tree.body)
|
|
831
|
+
|
|
802
832
|
# Execute with include-chain tracking
|
|
803
833
|
ctx.include_chain.append(resolved)
|
|
804
834
|
try:
|
|
@@ -915,6 +945,10 @@ def execute(script: Script, *, ctx: RuntimeContext | None = None) -> None:
|
|
|
915
945
|
except (OSError, ValueError):
|
|
916
946
|
ctx.include_chain.append(script.source)
|
|
917
947
|
set_static_system_vars(ctx)
|
|
948
|
+
# Pre-register all SCRIPT blocks so forward references work.
|
|
949
|
+
# The legacy engine registered scripts at parse time (two-pass);
|
|
950
|
+
# the AST executor must do an explicit pre-scan.
|
|
951
|
+
_pre_register_scripts(ctx, script.body)
|
|
918
952
|
# Push a root frame so commandliststack is never empty during AST
|
|
919
953
|
# execution. This ensures get_subvarset(), current_script_line(),
|
|
920
954
|
# xf_sub_defined(), the REPL, and all other commandliststack readers
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: execsql2
|
|
3
|
-
Version: 2.16.
|
|
3
|
+
Version: 2.16.5
|
|
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
|
|
6
6
|
Project-URL: Repository, https://github.com/geocoug/execsql
|
|
@@ -29,7 +29,7 @@ execsql/db/postgres.py,sha256=-GpaA9fi6_vdIDTGyRGxNRaPYAAkEB_aCb-EyLFShsM,21120
|
|
|
29
29
|
execsql/db/sqlite.py,sha256=or2JDDt_MyBTAtSXBVhNTcojE9jCE4b98tq39sNOyUg,10401
|
|
30
30
|
execsql/db/sqlserver.py,sha256=d8PwfNumt-Spit_0llafqQ900suv3CZMbrRsHLU1iB4,7683
|
|
31
31
|
execsql/debug/__init__.py,sha256=j6EGUR0dHzUhWN1mHHtf1-Lhjq3Sb1V-vmnq2Ztgj1M,178
|
|
32
|
-
execsql/debug/repl.py,sha256=
|
|
32
|
+
execsql/debug/repl.py,sha256=rlddBAg7lelHYmeyeXhDqkK8XkKF2t2dVv4nsEMvleU,18247
|
|
33
33
|
execsql/exporters/__init__.py,sha256=-Cnji-OgodJV8ftcDcOyTof0kQMy9J5kKVC8GVFpc3o,670
|
|
34
34
|
execsql/exporters/base.py,sha256=Uhq0PBz8N_pJ7WlIN9225wY-HyxfzWSb9YabHXicBA8,6387
|
|
35
35
|
execsql/exporters/delimited.py,sha256=Po9RV4UwBLOuRZmPFJk5CErpFvTdLCy--nFJJffZgxM,32383
|
|
@@ -84,7 +84,7 @@ execsql/script/__init__.py,sha256=3WaBklMVIWjtCsYQ-BVo9UAVEIATOgeGsuyv21YKnxo,39
|
|
|
84
84
|
execsql/script/ast.py,sha256=yFw9ZvLLDNNSmSgy7cwK2fXLatpp2CKYAAyOneJoKVc,18836
|
|
85
85
|
execsql/script/control.py,sha256=s-1eZdGARM6H1FwZ6VDdO_f50j7bvvRtTHesfUm9tbc,6144
|
|
86
86
|
execsql/script/engine.py,sha256=EhuVBniOrFkzAW4I3NIZLt3INHTZJvlYoF7B99rZBLI,29391
|
|
87
|
-
execsql/script/executor.py,sha256=
|
|
87
|
+
execsql/script/executor.py,sha256=YbvoviWeUv9dcT-FWtAY4IsvhC9d6MvtHRtTNXkZL4s,35931
|
|
88
88
|
execsql/script/parser.py,sha256=nAyLaDP-nL6C-chvlaSu0Oqh8ACcCCZjFacv0Fhyp58,24983
|
|
89
89
|
execsql/script/variables.py,sha256=ZSBGQUsoii6w3dLDVY9xxoPIV6wY0sAV_BNIQ6pgQAE,14328
|
|
90
90
|
execsql/utils/__init__.py,sha256=0uR6JwVJQRX3vceByNBduCAf5dd5assKjeqJUWvpZoA,278
|
|
@@ -99,24 +99,24 @@ execsql/utils/numeric.py,sha256=xh02ANSRk3nUpQ-rtm66ILoMqoi7HtzCoRMIOT9U8QI,1570
|
|
|
99
99
|
execsql/utils/regex.py,sha256=diEzTZqU_HHwVMadPAvN1Vgzhl7I03eVaEFGCXyGGL8,3770
|
|
100
100
|
execsql/utils/strings.py,sha256=5Dvzrk-9SIw2lpxXZQkiJbNyo1sy7iXXAtSULlZ0KG8,8488
|
|
101
101
|
execsql/utils/timer.py,sha256=eDYf5VzCNFk7oo90InJucUm3XcBdhYMogjZMqeg9xzc,1899
|
|
102
|
-
execsql2-2.16.
|
|
103
|
-
execsql2-2.16.
|
|
104
|
-
execsql2-2.16.
|
|
105
|
-
execsql2-2.16.
|
|
106
|
-
execsql2-2.16.
|
|
107
|
-
execsql2-2.16.
|
|
108
|
-
execsql2-2.16.
|
|
109
|
-
execsql2-2.16.
|
|
110
|
-
execsql2-2.16.
|
|
111
|
-
execsql2-2.16.
|
|
112
|
-
execsql2-2.16.
|
|
113
|
-
execsql2-2.16.
|
|
114
|
-
execsql2-2.16.
|
|
115
|
-
execsql2-2.16.
|
|
116
|
-
execsql2-2.16.
|
|
117
|
-
execsql2-2.16.
|
|
118
|
-
execsql2-2.16.
|
|
119
|
-
execsql2-2.16.
|
|
120
|
-
execsql2-2.16.
|
|
121
|
-
execsql2-2.16.
|
|
122
|
-
execsql2-2.16.
|
|
102
|
+
execsql2-2.16.5.data/data/execsql2_extras/README.md,sha256=sxwVyU0ZahCfANv56LahkyuM505kFjrMhe-1SvWE69E,4845
|
|
103
|
+
execsql2-2.16.5.data/data/execsql2_extras/config_settings.sqlite,sha256=aY5cxR7Q7J6zJ4bC9lu5mHUrhy211Cq3MNKPQVCt02E,20480
|
|
104
|
+
execsql2-2.16.5.data/data/execsql2_extras/example_config_prompt.sql,sha256=SY3Jxn1qcVm4kPW9xmmTfknHfvURXmeEYTbRjYrjGSw,7487
|
|
105
|
+
execsql2-2.16.5.data/data/execsql2_extras/execsql.conf,sha256=_45iJ-KWZnB8uMW_gEg067MM5pmGJ-dVl7VbAZMunAE,9530
|
|
106
|
+
execsql2-2.16.5.data/data/execsql2_extras/make_config_db.sql,sha256=WwyC6dK-Eh5CAVppiBCDHqiI1_wEI9U95Ytpr4lsZkg,8726
|
|
107
|
+
execsql2-2.16.5.data/data/execsql2_extras/md_compare.sql,sha256=B8Wd7LZ0vnMY2qvA139JIEBkPObgRH2i5xj6PejTQt8,24092
|
|
108
|
+
execsql2-2.16.5.data/data/execsql2_extras/md_glossary.sql,sha256=DJRHcU5NbFpxTTX-IwH3yRlsboj1q6BBGrUAHKn4Cuo,10796
|
|
109
|
+
execsql2-2.16.5.data/data/execsql2_extras/md_upsert.sql,sha256=v_7GbWh_N1mBTmw3gvTrkagOVp2q0KmXvM8hE-DlFxY,112524
|
|
110
|
+
execsql2-2.16.5.data/data/execsql2_extras/pg_compare.sql,sha256=9dWa8hnfy5dVJI-z2iGpd9JzQmI4j2ziMlEdpnr66ro,24352
|
|
111
|
+
execsql2-2.16.5.data/data/execsql2_extras/pg_glossary.sql,sha256=pKjIIDsROAgJq2H-1qNEcRMAWManivcZ_AEVHzUUlic,9908
|
|
112
|
+
execsql2-2.16.5.data/data/execsql2_extras/pg_upsert.sql,sha256=k7AFiGTLBy3nf-qO5QIaZrEYTAKvdxxU3JDLx9jqkzs,108315
|
|
113
|
+
execsql2-2.16.5.data/data/execsql2_extras/script_template.sql,sha256=1Estacb_vm1FgK41k_G9nuduP1yiA-fQ1Kn4Z4mv5Ao,11153
|
|
114
|
+
execsql2-2.16.5.data/data/execsql2_extras/ss_compare.sql,sha256=TsVxWm3cEpR5-EiMYXNhtaY0arSNeKZhsJdHdLA7xeI,24833
|
|
115
|
+
execsql2-2.16.5.data/data/execsql2_extras/ss_glossary.sql,sha256=cLM7nN8JOIu9ZVP9oY9qdSK3hrnWJiDcX6nZmQQbQWI,13065
|
|
116
|
+
execsql2-2.16.5.data/data/execsql2_extras/ss_upsert.sql,sha256=BCqmBykXBF-BpCgOFeG1qhf2XfScKsxPD17wd1hYfHw,120647
|
|
117
|
+
execsql2-2.16.5.dist-info/METADATA,sha256=xobEE16MgxSLPqPT019E5OTTsnADPhaPzNwSt_4rgpE,20920
|
|
118
|
+
execsql2-2.16.5.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
119
|
+
execsql2-2.16.5.dist-info/entry_points.txt,sha256=sUOxkM-dN1eBGGpSpDLsAaE0yNXYQKWZAfxPOlMkQyk,90
|
|
120
|
+
execsql2-2.16.5.dist-info/licenses/LICENSE.txt,sha256=LBdhuxejF8_bLCHZ2kWfmDXpDGUu914Gbd6_3JjCRe0,676
|
|
121
|
+
execsql2-2.16.5.dist-info/licenses/NOTICE,sha256=sqVrM73Ys9zfvWC_P797lHfTnoPW_ETeBSrUTFaob0A,339
|
|
122
|
+
execsql2-2.16.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
{execsql2-2.16.3.data → execsql2-2.16.5.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
|
|
File without changes
|
|
File without changes
|