execsql2 2.37.0__py3-none-any.whl → 2.39.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.
- execsql/api.py +95 -45
- execsql/cli/commands/run.py +2 -2
- execsql/cli/lint.py +46 -9
- execsql/cli/run.py +128 -56
- execsql/config.py +7 -0
- execsql/data/execsql.conf.template +26 -2
- execsql/db/base.py +61 -24
- execsql/db/dsn.py +2 -3
- execsql/db/duckdb.py +43 -4
- execsql/db/firebird.py +39 -22
- execsql/db/mysql.py +22 -23
- execsql/db/oracle.py +11 -4
- execsql/db/postgres.py +15 -20
- execsql/db/sqlite.py +117 -10
- execsql/db/sqlserver.py +11 -7
- execsql/db/target_types.py +151 -4
- execsql/debug/repl.py +2 -1
- execsql/exceptions.py +19 -0
- execsql/exporters/html.py +26 -42
- execsql/exporters/ods.py +93 -21
- execsql/exporters/sqlite.py +82 -47
- execsql/format.py +12 -4
- execsql/gui/__init__.py +13 -10
- execsql/gui/base.py +131 -8
- execsql/gui/console.py +77 -30
- execsql/gui/desktop.py +290 -119
- execsql/gui/tui.py +384 -129
- execsql/importers/base.py +15 -19
- execsql/importers/csv.py +3 -5
- execsql/importers/json.py +37 -13
- execsql/importers/ods.py +22 -2
- execsql/lsp/document.py +6 -1
- execsql/lsp/hover.py +2 -1
- execsql/metacommands/conditions.py +3 -1
- execsql/metacommands/connect.py +18 -3
- execsql/metacommands/control.py +20 -5
- execsql/metacommands/data.py +11 -9
- execsql/metacommands/dispatch.py +10 -0
- execsql/metacommands/io.py +1 -0
- execsql/metacommands/io_export.py +1 -2
- execsql/metacommands/io_fileops.py +27 -91
- execsql/metacommands/io_import.py +26 -8
- execsql/metacommands/io_write.py +0 -9
- execsql/metacommands/prompt.py +94 -42
- execsql/metacommands/reference.py +7 -0
- execsql/metacommands/system.py +0 -2
- execsql/parser.py +132 -45
- execsql/script/control.py +17 -7
- execsql/script/engine.py +1 -1
- execsql/script/executor.py +184 -37
- execsql/script/preparation.py +42 -0
- execsql/types.py +6 -5
- execsql/utils/auth.py +11 -6
- execsql/utils/errors.py +2 -2
- execsql/utils/fileio.py +342 -134
- execsql/utils/gui.py +162 -53
- execsql/utils/spreadsheet.py +74 -0
- execsql/utils/strings.py +13 -7
- {execsql2-2.37.0.data → execsql2-2.39.1.data}/data/execsql2_extras/README.md +5 -5
- {execsql2-2.37.0.data → execsql2-2.39.1.data}/data/execsql2_extras/example_config_prompt.sql +2 -2
- {execsql2-2.37.0.dist-info → execsql2-2.39.1.dist-info}/METADATA +32 -119
- {execsql2-2.37.0.dist-info → execsql2-2.39.1.dist-info}/RECORD +77 -75
- {execsql2-2.37.0.dist-info → execsql2-2.39.1.dist-info}/WHEEL +1 -1
- {execsql2-2.37.0.data → execsql2-2.39.1.data}/data/execsql2_extras/config_settings.sqlite +0 -0
- {execsql2-2.37.0.data → execsql2-2.39.1.data}/data/execsql2_extras/make_config_db.sql +0 -0
- {execsql2-2.37.0.data → execsql2-2.39.1.data}/data/execsql2_extras/md_compare.sql +0 -0
- {execsql2-2.37.0.data → execsql2-2.39.1.data}/data/execsql2_extras/md_glossary.sql +0 -0
- {execsql2-2.37.0.data → execsql2-2.39.1.data}/data/execsql2_extras/md_upsert.sql +0 -0
- {execsql2-2.37.0.data → execsql2-2.39.1.data}/data/execsql2_extras/pg_compare.sql +0 -0
- {execsql2-2.37.0.data → execsql2-2.39.1.data}/data/execsql2_extras/pg_glossary.sql +0 -0
- {execsql2-2.37.0.data → execsql2-2.39.1.data}/data/execsql2_extras/script_template.sql +0 -0
- {execsql2-2.37.0.data → execsql2-2.39.1.data}/data/execsql2_extras/ss_compare.sql +0 -0
- {execsql2-2.37.0.data → execsql2-2.39.1.data}/data/execsql2_extras/ss_glossary.sql +0 -0
- {execsql2-2.37.0.data → execsql2-2.39.1.data}/data/execsql2_extras/ss_upsert.sql +0 -0
- {execsql2-2.37.0.dist-info → execsql2-2.39.1.dist-info}/entry_points.txt +0 -0
- {execsql2-2.37.0.dist-info → execsql2-2.39.1.dist-info}/licenses/LICENSE.txt +0 -0
- {execsql2-2.37.0.dist-info → execsql2-2.39.1.dist-info}/licenses/NOTICE +0 -0
execsql/gui/console.py
CHANGED
|
@@ -16,6 +16,7 @@ from execsql.gui.base import (
|
|
|
16
16
|
compare_stats as _compare_stats,
|
|
17
17
|
compute_row_diffs,
|
|
18
18
|
format_table,
|
|
19
|
+
normalize_text_entry,
|
|
19
20
|
row_count_text as _row_count_text,
|
|
20
21
|
)
|
|
21
22
|
|
|
@@ -143,17 +144,26 @@ class ConsoleBackend(GuiBackend):
|
|
|
143
144
|
_print_table(headers, rows)
|
|
144
145
|
print(f" {_row_count_text(len(rows))}", file=sys.stderr)
|
|
145
146
|
|
|
146
|
-
|
|
147
|
-
|
|
147
|
+
if not textentry:
|
|
148
|
+
return {"button": _prompt_buttons(button_list), "return_value": None}
|
|
149
|
+
while True:
|
|
148
150
|
if hidetext:
|
|
149
151
|
import getpass
|
|
150
152
|
|
|
151
|
-
|
|
153
|
+
entered = getpass.getpass("Enter value: ")
|
|
152
154
|
else:
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
entered = input(f"Enter value [{initial or ''}]: ")
|
|
156
|
+
if not entered:
|
|
157
|
+
entered = initial or ""
|
|
158
|
+
btn = _prompt_buttons(button_list)
|
|
159
|
+
if btn is None:
|
|
160
|
+
return {"button": None, "return_value": None}
|
|
161
|
+
try:
|
|
162
|
+
value = normalize_text_entry(entered, args.get("textentrytype"), args.get("textentrycase"))
|
|
163
|
+
except ValueError as exc:
|
|
164
|
+
print(f"Invalid entry: {exc}", file=sys.stderr)
|
|
165
|
+
continue
|
|
166
|
+
return {"button": btn, "return_value": value}
|
|
157
167
|
|
|
158
168
|
def show_entry_form(self, args: dict) -> dict:
|
|
159
169
|
title = args.get("title", "Entry")
|
|
@@ -306,7 +316,7 @@ class ConsoleBackend(GuiBackend):
|
|
|
306
316
|
print("(Row selection requires a GUI backend; displaying source data only.)", file=sys.stderr)
|
|
307
317
|
|
|
308
318
|
btn = _prompt_buttons(button_list)
|
|
309
|
-
return {"button": btn}
|
|
319
|
+
return {"button": btn, "rows": None}
|
|
310
320
|
|
|
311
321
|
def show_select_sub(self, args: dict) -> dict:
|
|
312
322
|
title = args.get("title", "Select a row")
|
|
@@ -317,15 +327,27 @@ class ConsoleBackend(GuiBackend):
|
|
|
317
327
|
print(f"\n=== {title} ===", file=sys.stderr)
|
|
318
328
|
if message:
|
|
319
329
|
print(message, file=sys.stderr)
|
|
330
|
+
_print_help_url(args)
|
|
331
|
+
can_continue = any(button[1] == 2 for button in args.get("button_list", []))
|
|
320
332
|
if headers and rows:
|
|
321
333
|
for i, row in enumerate(rows, 1):
|
|
322
334
|
print(f" [{i}] " + ", ".join(f"{h}={v}" for h, v in zip(headers, row)), file=sys.stderr)
|
|
323
335
|
while True:
|
|
324
|
-
|
|
336
|
+
prompt = (
|
|
337
|
+
"Select row number, C to continue without selecting, or blank to cancel: "
|
|
338
|
+
if can_continue
|
|
339
|
+
else "Select row number (or blank to cancel): "
|
|
340
|
+
)
|
|
341
|
+
try:
|
|
342
|
+
raw = input(prompt).strip()
|
|
343
|
+
except EOFError:
|
|
344
|
+
raw = ""
|
|
325
345
|
if not raw:
|
|
326
346
|
return {"button": None, "row": None}
|
|
347
|
+
if can_continue and raw.lower() == "c":
|
|
348
|
+
return {"button": 2, "row": None}
|
|
327
349
|
if raw.isdigit() and 1 <= int(raw) <= len(rows):
|
|
328
|
-
row =
|
|
350
|
+
row = list(rows[int(raw) - 1])
|
|
329
351
|
return {"button": 1, "row": row}
|
|
330
352
|
print("Invalid selection.", file=sys.stderr)
|
|
331
353
|
return {"button": None, "row": None}
|
|
@@ -342,27 +364,43 @@ class ConsoleBackend(GuiBackend):
|
|
|
342
364
|
print(message, file=sys.stderr)
|
|
343
365
|
_print_help_url(args)
|
|
344
366
|
if headers and rows:
|
|
345
|
-
_print_table(headers, rows)
|
|
367
|
+
_print_table(["#", *headers], [(i + 1, *row) for i, row in enumerate(rows)])
|
|
346
368
|
print(f" {_row_count_text(len(rows))}", file=sys.stderr)
|
|
347
369
|
|
|
348
|
-
if not button_specs:
|
|
349
|
-
input("Press Enter to continue...")
|
|
350
|
-
return {"button": 1}
|
|
351
|
-
|
|
352
370
|
print("\nAvailable actions:", file=sys.stderr)
|
|
353
371
|
for i, spec in enumerate(button_specs, 1):
|
|
354
|
-
|
|
372
|
+
required = " (select a data row first)" if spec.data_required else ""
|
|
373
|
+
print(f" [{i}] {spec.label} — {spec.prompt}{required}", file=sys.stderr)
|
|
374
|
+
if headers and rows:
|
|
375
|
+
print(" R <number>: select a data row", file=sys.stderr)
|
|
376
|
+
print(" Blank input: Cancel", file=sys.stderr)
|
|
355
377
|
|
|
356
378
|
include_continue = args.get("include_continue_button")
|
|
357
379
|
if include_continue:
|
|
358
380
|
print(" [0] Continue", file=sys.stderr)
|
|
359
381
|
|
|
382
|
+
selected_row = None
|
|
360
383
|
while True:
|
|
361
|
-
|
|
384
|
+
try:
|
|
385
|
+
raw = input("Select action or data row: ").strip()
|
|
386
|
+
except EOFError:
|
|
387
|
+
raw = ""
|
|
388
|
+
if not raw or raw == "\x1b":
|
|
389
|
+
return {"button": None, "row": None}
|
|
362
390
|
if include_continue and raw == "0":
|
|
363
|
-
return {"button":
|
|
391
|
+
return {"button": 0, "row": None}
|
|
392
|
+
parts = raw.split()
|
|
393
|
+
if len(parts) == 2 and parts[0].lower() == "r" and parts[1].isdigit():
|
|
394
|
+
index = int(parts[1]) - 1
|
|
395
|
+
if rows and 0 <= index < len(rows):
|
|
396
|
+
selected_row = list(rows[index])
|
|
397
|
+
continue
|
|
364
398
|
if raw.isdigit() and 1 <= int(raw) <= len(button_specs):
|
|
365
|
-
|
|
399
|
+
index = int(raw) - 1
|
|
400
|
+
if button_specs[index].data_required and selected_row is None:
|
|
401
|
+
print("Select a data row before choosing this action.", file=sys.stderr)
|
|
402
|
+
continue
|
|
403
|
+
return {"button": index + 1, "row": selected_row if button_specs[index].data_required else None}
|
|
366
404
|
print("Invalid choice.", file=sys.stderr)
|
|
367
405
|
|
|
368
406
|
def show_map(self, args: dict) -> dict:
|
|
@@ -450,14 +488,23 @@ class ConsoleBackend(GuiBackend):
|
|
|
450
488
|
for k, v in db_types.items():
|
|
451
489
|
print(f" {k} — {v}", file=sys.stderr)
|
|
452
490
|
db_type = input("Database type: ").strip().lower()
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
"
|
|
462
|
-
|
|
463
|
-
|
|
491
|
+
while db_type not in db_types:
|
|
492
|
+
print("Select one of the listed database types.", file=sys.stderr)
|
|
493
|
+
db_type = input("Database type: ").strip().lower()
|
|
494
|
+
import getpass
|
|
495
|
+
|
|
496
|
+
from execsql.gui.base import FILE_DATABASES, connection_result
|
|
497
|
+
|
|
498
|
+
if db_type in FILE_DATABASES:
|
|
499
|
+
return dict(connection_result(db_type, database=input("File path: ")))
|
|
500
|
+
server = input("Server (or blank): ") if db_type != "d" else ""
|
|
501
|
+
database = input("DSN: " if db_type == "d" else "Database (or blank): ")
|
|
502
|
+
username = input("Username (or blank): ")
|
|
503
|
+
password = getpass.getpass("Password (blank: no additional password prompt): ")
|
|
504
|
+
encoding = input("Encoding (blank: driver default): ")
|
|
505
|
+
while True:
|
|
506
|
+
port = input("Port (blank: DBMS default): ") if db_type != "d" else ""
|
|
507
|
+
try:
|
|
508
|
+
return dict(connection_result(db_type, server, database, username, password, port, encoding))
|
|
509
|
+
except ValueError as exc:
|
|
510
|
+
print(str(exc), file=sys.stderr)
|