execsql2 2.16.13__py3-none-any.whl → 2.16.14__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/db/base.py +2 -0
- execsql/metacommands/io_export.py +14 -10
- execsql/metacommands/io_fileops.py +4 -6
- execsql/script/ast.py +3 -0
- execsql/script/executor.py +7 -3
- execsql/script/parser.py +20 -14
- {execsql2-2.16.13.dist-info → execsql2-2.16.14.dist-info}/METADATA +1 -1
- {execsql2-2.16.13.dist-info → execsql2-2.16.14.dist-info}/RECORD +27 -27
- {execsql2-2.16.13.data → execsql2-2.16.14.data}/data/execsql2_extras/README.md +0 -0
- {execsql2-2.16.13.data → execsql2-2.16.14.data}/data/execsql2_extras/config_settings.sqlite +0 -0
- {execsql2-2.16.13.data → execsql2-2.16.14.data}/data/execsql2_extras/example_config_prompt.sql +0 -0
- {execsql2-2.16.13.data → execsql2-2.16.14.data}/data/execsql2_extras/execsql.conf +0 -0
- {execsql2-2.16.13.data → execsql2-2.16.14.data}/data/execsql2_extras/make_config_db.sql +0 -0
- {execsql2-2.16.13.data → execsql2-2.16.14.data}/data/execsql2_extras/md_compare.sql +0 -0
- {execsql2-2.16.13.data → execsql2-2.16.14.data}/data/execsql2_extras/md_glossary.sql +0 -0
- {execsql2-2.16.13.data → execsql2-2.16.14.data}/data/execsql2_extras/md_upsert.sql +0 -0
- {execsql2-2.16.13.data → execsql2-2.16.14.data}/data/execsql2_extras/pg_compare.sql +0 -0
- {execsql2-2.16.13.data → execsql2-2.16.14.data}/data/execsql2_extras/pg_glossary.sql +0 -0
- {execsql2-2.16.13.data → execsql2-2.16.14.data}/data/execsql2_extras/pg_upsert.sql +0 -0
- {execsql2-2.16.13.data → execsql2-2.16.14.data}/data/execsql2_extras/script_template.sql +0 -0
- {execsql2-2.16.13.data → execsql2-2.16.14.data}/data/execsql2_extras/ss_compare.sql +0 -0
- {execsql2-2.16.13.data → execsql2-2.16.14.data}/data/execsql2_extras/ss_glossary.sql +0 -0
- {execsql2-2.16.13.data → execsql2-2.16.14.data}/data/execsql2_extras/ss_upsert.sql +0 -0
- {execsql2-2.16.13.dist-info → execsql2-2.16.14.dist-info}/WHEEL +0 -0
- {execsql2-2.16.13.dist-info → execsql2-2.16.14.dist-info}/entry_points.txt +0 -0
- {execsql2-2.16.13.dist-info → execsql2-2.16.14.dist-info}/licenses/LICENSE.txt +0 -0
- {execsql2-2.16.13.dist-info → execsql2-2.16.14.dist-info}/licenses/NOTICE +0 -0
execsql/db/base.py
CHANGED
|
@@ -226,6 +226,7 @@ class Database(ABC):
|
|
|
226
226
|
try:
|
|
227
227
|
curs.execute(sql)
|
|
228
228
|
except Exception:
|
|
229
|
+
curs.close()
|
|
229
230
|
self.rollback()
|
|
230
231
|
raise
|
|
231
232
|
try:
|
|
@@ -264,6 +265,7 @@ class Database(ABC):
|
|
|
264
265
|
try:
|
|
265
266
|
curs.execute(sql)
|
|
266
267
|
except Exception:
|
|
268
|
+
curs.close()
|
|
267
269
|
self.rollback()
|
|
268
270
|
raise
|
|
269
271
|
try:
|
|
@@ -136,16 +136,20 @@ def _dispatch_format(
|
|
|
136
136
|
raise
|
|
137
137
|
except Exception as e:
|
|
138
138
|
raise ErrInfo("db", select_stmt, exception_msg=exception_desc()) from e
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
139
|
+
try:
|
|
140
|
+
if filefmt == "raw":
|
|
141
|
+
write_query_raw(outfile, rows, db.encoding, append, zipfile=zipfilename)
|
|
142
|
+
elif filefmt == "b64":
|
|
143
|
+
write_query_b64(outfile, rows, append, zipfile=zipfilename)
|
|
144
|
+
elif filefmt == "feather":
|
|
145
|
+
write_query_to_feather(outfile, hdrs, rows)
|
|
146
|
+
elif filefmt == "parquet":
|
|
147
|
+
write_query_to_parquet(outfile, hdrs, rows)
|
|
148
|
+
else:
|
|
149
|
+
write_delimited_file(outfile, filefmt, hdrs, rows, _state.conf.output_encoding, append, zipfilename)
|
|
150
|
+
except BaseException:
|
|
151
|
+
rows.close()
|
|
152
|
+
raise
|
|
149
153
|
|
|
150
154
|
|
|
151
155
|
# ---------------------------------------------------------------------------
|
|
@@ -106,10 +106,9 @@ def x_copy(**kwargs: Any) -> None:
|
|
|
106
106
|
try:
|
|
107
107
|
db2.populate_table(schema2, table2, rows, hdrs, get_ts)
|
|
108
108
|
db2.commit()
|
|
109
|
-
except
|
|
109
|
+
except BaseException:
|
|
110
|
+
rows.close()
|
|
110
111
|
raise
|
|
111
|
-
except Exception as e:
|
|
112
|
-
raise ErrInfo("db", select_stmt, exception_msg=exception_desc()) from e
|
|
113
112
|
|
|
114
113
|
|
|
115
114
|
def x_copy_query(**kwargs: Any) -> None:
|
|
@@ -181,10 +180,9 @@ def x_copy_query(**kwargs: Any) -> None:
|
|
|
181
180
|
try:
|
|
182
181
|
db2.populate_table(schema2, table2, rows, hdrs, get_ts)
|
|
183
182
|
db2.commit()
|
|
184
|
-
except
|
|
183
|
+
except BaseException:
|
|
184
|
+
rows.close()
|
|
185
185
|
raise
|
|
186
|
-
except Exception as e:
|
|
187
|
-
raise ErrInfo("db", select_stmt, exception_msg=exception_desc()) from e
|
|
188
186
|
|
|
189
187
|
|
|
190
188
|
def x_zip(**kwargs: Any) -> None:
|
execsql/script/ast.py
CHANGED
|
@@ -209,11 +209,14 @@ class ElseIfClause:
|
|
|
209
209
|
Attributes:
|
|
210
210
|
condition: The condition expression text (e.g. ``"HAS_ROWS"``).
|
|
211
211
|
span: Source location of the ELSEIF line itself.
|
|
212
|
+
condition_modifiers: ANDIF/ORIF modifiers that compound the ELSEIF
|
|
213
|
+
condition, evaluated left-to-right at runtime.
|
|
212
214
|
body: Nodes executed when this condition is true.
|
|
213
215
|
"""
|
|
214
216
|
|
|
215
217
|
condition: str
|
|
216
218
|
span: SourceSpan
|
|
219
|
+
condition_modifiers: list[ConditionModifier] = field(default_factory=list)
|
|
217
220
|
body: list[Node] = field(default_factory=list)
|
|
218
221
|
|
|
219
222
|
|
execsql/script/executor.py
CHANGED
|
@@ -384,6 +384,12 @@ def _execute_node(
|
|
|
384
384
|
ctx.last_command = _FakeScriptCmd(node)
|
|
385
385
|
_execute_include(ctx, node, localvars)
|
|
386
386
|
|
|
387
|
+
else:
|
|
388
|
+
raise ErrInfo(
|
|
389
|
+
type="error",
|
|
390
|
+
other_msg=f"Unhandled AST node type: {type(node).__name__} at {node.span}",
|
|
391
|
+
)
|
|
392
|
+
|
|
387
393
|
|
|
388
394
|
# ---------------------------------------------------------------------------
|
|
389
395
|
# Block executors
|
|
@@ -404,9 +410,7 @@ def _execute_if(
|
|
|
404
410
|
|
|
405
411
|
# Try ELSEIF clauses
|
|
406
412
|
for clause in node.elseif_clauses:
|
|
407
|
-
|
|
408
|
-
expanded = substitute_vars(clause.condition, effective_locals, ctx=ctx)
|
|
409
|
-
if xcmd_test(expanded):
|
|
413
|
+
if _eval_condition(ctx, clause.condition, clause.condition_modifiers):
|
|
410
414
|
_execute_nodes(ctx, clause.body, node.span.file, localvars, in_loop=in_loop)
|
|
411
415
|
return
|
|
412
416
|
|
execsql/script/parser.py
CHANGED
|
@@ -580,14 +580,17 @@ def _parse_lines(lines: Iterable[str], source_name: str) -> Script:
|
|
|
580
580
|
command_text=line,
|
|
581
581
|
other_msg=f"ANDIF without matching IF on line {file_lineno} of {source_name}.",
|
|
582
582
|
)
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
condition=m.group("cond").strip(),
|
|
588
|
-
span=SourceSpan(source_name, file_lineno),
|
|
589
|
-
),
|
|
583
|
+
modifier = ConditionModifier(
|
|
584
|
+
kind="AND",
|
|
585
|
+
condition=m.group("cond").strip(),
|
|
586
|
+
span=SourceSpan(source_name, file_lineno),
|
|
590
587
|
)
|
|
588
|
+
frame = block_stack[-1]
|
|
589
|
+
if_node = frame.node
|
|
590
|
+
if frame._in_elseif and if_node.elseif_clauses: # type: ignore[union-attr]
|
|
591
|
+
if_node.elseif_clauses[-1].condition_modifiers.append(modifier) # type: ignore[union-attr]
|
|
592
|
+
else:
|
|
593
|
+
if_node.condition_modifiers.append(modifier) # type: ignore[union-attr]
|
|
591
594
|
continue
|
|
592
595
|
|
|
593
596
|
# -- ORIF --
|
|
@@ -599,14 +602,17 @@ def _parse_lines(lines: Iterable[str], source_name: str) -> Script:
|
|
|
599
602
|
command_text=line,
|
|
600
603
|
other_msg=f"ORIF without matching IF on line {file_lineno} of {source_name}.",
|
|
601
604
|
)
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
condition=m.group("cond").strip(),
|
|
607
|
-
span=SourceSpan(source_name, file_lineno),
|
|
608
|
-
),
|
|
605
|
+
modifier = ConditionModifier(
|
|
606
|
+
kind="OR",
|
|
607
|
+
condition=m.group("cond").strip(),
|
|
608
|
+
span=SourceSpan(source_name, file_lineno),
|
|
609
609
|
)
|
|
610
|
+
frame = block_stack[-1]
|
|
611
|
+
if_node = frame.node
|
|
612
|
+
if frame._in_elseif and if_node.elseif_clauses: # type: ignore[union-attr]
|
|
613
|
+
if_node.elseif_clauses[-1].condition_modifiers.append(modifier) # type: ignore[union-attr]
|
|
614
|
+
else:
|
|
615
|
+
if_node.condition_modifiers.append(modifier) # type: ignore[union-attr]
|
|
610
616
|
continue
|
|
611
617
|
|
|
612
618
|
# -- ELSE --
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: execsql2
|
|
3
|
-
Version: 2.16.
|
|
3
|
+
Version: 2.16.14
|
|
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
|
|
@@ -18,7 +18,7 @@ execsql/cli/lint_ast.py,sha256=c9UEFsZ7PZlFdrK0zJCe-WXfCqvS3WlOUWEycZozqB8,14688
|
|
|
18
18
|
execsql/cli/run.py,sha256=QrJ5SqIGiRO5AXavmxyhlJCMGtgZydC8MtHHAieQ4II,34571
|
|
19
19
|
execsql/db/__init__.py,sha256=jTbuafuKOqYtXFR1wvCOoKK5Lr3l1uErfaIbIr6UywI,1063
|
|
20
20
|
execsql/db/access.py,sha256=dAFuP1YeL7e7sy13T-9wll2Av5cr_PcUdxHf1NlvRNY,18204
|
|
21
|
-
execsql/db/base.py,sha256
|
|
21
|
+
execsql/db/base.py,sha256=lUhS9yGNX4Nhxfu1wxjLdGbLoabcDYXZQB_5VUw5kqE,31372
|
|
22
22
|
execsql/db/dsn.py,sha256=ZkKQrRgNr8VilOhE7jzLIZKVhrmEL0Bt3BppegQ03KM,5486
|
|
23
23
|
execsql/db/duckdb.py,sha256=79lRzKRhw1Pjfqcrba27S4Oq8a8AbDO_d0XkaNKKPQo,3197
|
|
24
24
|
execsql/db/factory.py,sha256=YHdgyqQYy16548O3fGyElLC5C7DdIgva4Z29OsDxXjs,5367
|
|
@@ -72,8 +72,8 @@ execsql/metacommands/data.py,sha256=tRQBGTAuW-eJ2tBNWaoZI9OjTyNNyHJISo7gOdL-sm8,
|
|
|
72
72
|
execsql/metacommands/debug.py,sha256=3QVm0N5uc7mcZco36kqlDq8tiWW0sdo8E8BoQZkE_DI,11784
|
|
73
73
|
execsql/metacommands/dispatch.py,sha256=Gao7rwiBFdghmYKcbWVm21Va30evobQuoghLY_FOZto,87602
|
|
74
74
|
execsql/metacommands/io.py,sha256=vlGBje5sgnqeilooMdhJDgSRIhysHy5_7LrKtik9Xjs,3011
|
|
75
|
-
execsql/metacommands/io_export.py,sha256=
|
|
76
|
-
execsql/metacommands/io_fileops.py,sha256=
|
|
75
|
+
execsql/metacommands/io_export.py,sha256=iX4L3lpZGT2P5ca2C3XJ3MYxXJ_loC7nWmfKcWv4UGQ,13379
|
|
76
|
+
execsql/metacommands/io_fileops.py,sha256=K7eHMAuCUEVpNITYnJhWaSmXtAnnx1ZaNIFnOwKtXzc,9456
|
|
77
77
|
execsql/metacommands/io_import.py,sha256=dXI4Bpar0i3Swm7xU-0naY8zLmV96Ie0hsrqBus22Nc,14176
|
|
78
78
|
execsql/metacommands/io_write.py,sha256=eayUxsLnEDqp2R5iqlEjeOK8DxyoOFkG9hBe2JkVR0A,8243
|
|
79
79
|
execsql/metacommands/prompt.py,sha256=E2e7q4pxbl_wEBrhco0B2gm5hO_HG3rNIF75PLdTgGg,36767
|
|
@@ -81,11 +81,11 @@ execsql/metacommands/script_ext.py,sha256=sw4YKUQl0SRlVlmhIoGbMokOo_hVqh1EcTuYCN
|
|
|
81
81
|
execsql/metacommands/system.py,sha256=azRbv_P8l0t8BkDM9bmAUkhpnLSLHSCcmByqs-a3FxQ,7352
|
|
82
82
|
execsql/metacommands/upsert.py,sha256=XE_P3mjaUkqT-LR4_28n2NbXwdjSgAGXJyZmKZC4Oy4,21136
|
|
83
83
|
execsql/script/__init__.py,sha256=3WaBklMVIWjtCsYQ-BVo9UAVEIATOgeGsuyv21YKnxo,3969
|
|
84
|
-
execsql/script/ast.py,sha256=
|
|
84
|
+
execsql/script/ast.py,sha256=AviMXseSpZtaPpJtJEs3olaXuk23kN_dU5raHbymy6s,20266
|
|
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=
|
|
88
|
-
execsql/script/parser.py,sha256=
|
|
87
|
+
execsql/script/executor.py,sha256=RclV-uG33yEWs8p_sj9KbW5IpHbmkRyG2DO5L4UJK50,37678
|
|
88
|
+
execsql/script/parser.py,sha256=a8ufVvyK6X-E6PbTiOpETscyi38XbiTypkgP8COHrQg,32171
|
|
89
89
|
execsql/script/variables.py,sha256=ZSBGQUsoii6w3dLDVY9xxoPIV6wY0sAV_BNIQ6pgQAE,14328
|
|
90
90
|
execsql/utils/__init__.py,sha256=0uR6JwVJQRX3vceByNBduCAf5dd5assKjeqJUWvpZoA,278
|
|
91
91
|
execsql/utils/auth.py,sha256=onXzNkNZQZxGC5w7eey06sjvAIAX_Lf9g7nUJtcsel0,7009
|
|
@@ -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.14.data/data/execsql2_extras/README.md,sha256=sxwVyU0ZahCfANv56LahkyuM505kFjrMhe-1SvWE69E,4845
|
|
103
|
+
execsql2-2.16.14.data/data/execsql2_extras/config_settings.sqlite,sha256=aY5cxR7Q7J6zJ4bC9lu5mHUrhy211Cq3MNKPQVCt02E,20480
|
|
104
|
+
execsql2-2.16.14.data/data/execsql2_extras/example_config_prompt.sql,sha256=SY3Jxn1qcVm4kPW9xmmTfknHfvURXmeEYTbRjYrjGSw,7487
|
|
105
|
+
execsql2-2.16.14.data/data/execsql2_extras/execsql.conf,sha256=_45iJ-KWZnB8uMW_gEg067MM5pmGJ-dVl7VbAZMunAE,9530
|
|
106
|
+
execsql2-2.16.14.data/data/execsql2_extras/make_config_db.sql,sha256=WwyC6dK-Eh5CAVppiBCDHqiI1_wEI9U95Ytpr4lsZkg,8726
|
|
107
|
+
execsql2-2.16.14.data/data/execsql2_extras/md_compare.sql,sha256=B8Wd7LZ0vnMY2qvA139JIEBkPObgRH2i5xj6PejTQt8,24092
|
|
108
|
+
execsql2-2.16.14.data/data/execsql2_extras/md_glossary.sql,sha256=DJRHcU5NbFpxTTX-IwH3yRlsboj1q6BBGrUAHKn4Cuo,10796
|
|
109
|
+
execsql2-2.16.14.data/data/execsql2_extras/md_upsert.sql,sha256=v_7GbWh_N1mBTmw3gvTrkagOVp2q0KmXvM8hE-DlFxY,112524
|
|
110
|
+
execsql2-2.16.14.data/data/execsql2_extras/pg_compare.sql,sha256=9dWa8hnfy5dVJI-z2iGpd9JzQmI4j2ziMlEdpnr66ro,24352
|
|
111
|
+
execsql2-2.16.14.data/data/execsql2_extras/pg_glossary.sql,sha256=pKjIIDsROAgJq2H-1qNEcRMAWManivcZ_AEVHzUUlic,9908
|
|
112
|
+
execsql2-2.16.14.data/data/execsql2_extras/pg_upsert.sql,sha256=k7AFiGTLBy3nf-qO5QIaZrEYTAKvdxxU3JDLx9jqkzs,108315
|
|
113
|
+
execsql2-2.16.14.data/data/execsql2_extras/script_template.sql,sha256=1Estacb_vm1FgK41k_G9nuduP1yiA-fQ1Kn4Z4mv5Ao,11153
|
|
114
|
+
execsql2-2.16.14.data/data/execsql2_extras/ss_compare.sql,sha256=TsVxWm3cEpR5-EiMYXNhtaY0arSNeKZhsJdHdLA7xeI,24833
|
|
115
|
+
execsql2-2.16.14.data/data/execsql2_extras/ss_glossary.sql,sha256=cLM7nN8JOIu9ZVP9oY9qdSK3hrnWJiDcX6nZmQQbQWI,13065
|
|
116
|
+
execsql2-2.16.14.data/data/execsql2_extras/ss_upsert.sql,sha256=BCqmBykXBF-BpCgOFeG1qhf2XfScKsxPD17wd1hYfHw,120647
|
|
117
|
+
execsql2-2.16.14.dist-info/METADATA,sha256=APNebYdwunkij8RDQOlTNkFS-BKMASdRLhNJefPx75o,20921
|
|
118
|
+
execsql2-2.16.14.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
119
|
+
execsql2-2.16.14.dist-info/entry_points.txt,sha256=sUOxkM-dN1eBGGpSpDLsAaE0yNXYQKWZAfxPOlMkQyk,90
|
|
120
|
+
execsql2-2.16.14.dist-info/licenses/LICENSE.txt,sha256=LBdhuxejF8_bLCHZ2kWfmDXpDGUu914Gbd6_3JjCRe0,676
|
|
121
|
+
execsql2-2.16.14.dist-info/licenses/NOTICE,sha256=sqVrM73Ys9zfvWC_P797lHfTnoPW_ETeBSrUTFaob0A,339
|
|
122
|
+
execsql2-2.16.14.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
{execsql2-2.16.13.data → execsql2-2.16.14.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
|