execsql2 2.39.1__py3-none-any.whl → 2.41.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.
Files changed (54) hide show
  1. execsql/__init__.py +4 -2
  2. execsql/api.py +40 -27
  3. execsql/cli/commands/__init__.py +1 -0
  4. execsql/cli/commands/inspect.py +292 -0
  5. execsql/cli/dispatch.py +3 -3
  6. execsql/cli/inspection.py +276 -0
  7. execsql/cli/lint.py +3 -4
  8. execsql/cli/options.py +15 -7
  9. execsql/config.py +15 -2
  10. execsql/db/access.py +6 -5
  11. execsql/db/base.py +14 -0
  12. execsql/db/dsn.py +3 -2
  13. execsql/db/duckdb.py +2 -1
  14. execsql/db/firebird.py +3 -2
  15. execsql/db/mysql.py +3 -2
  16. execsql/db/oracle.py +3 -2
  17. execsql/db/postgres.py +3 -2
  18. execsql/db/sqlite.py +2 -1
  19. execsql/db/sqlserver.py +3 -2
  20. execsql/ddl.py +310 -0
  21. execsql/exporters/xls.py +18 -4
  22. execsql/file_inspection.py +393 -0
  23. execsql/importers/base.py +19 -12
  24. execsql/importers/feather.py +16 -21
  25. execsql/importers/json.py +26 -32
  26. execsql/importers/xls.py +9 -4
  27. execsql/metacommands/control.py +21 -23
  28. execsql/metacommands/script_ext.py +6 -2
  29. execsql/schema.py +816 -0
  30. execsql/script/executor.py +11 -0
  31. execsql/script/parser.py +31 -0
  32. execsql/script/variables.py +14 -2
  33. execsql/utils/errors.py +21 -3
  34. {execsql2-2.39.1.data → execsql2-2.41.0.data}/data/execsql2_extras/README.md +7 -0
  35. execsql2-2.41.0.data/data/execsql2_extras/inspect/README.md +116 -0
  36. execsql2-2.41.0.data/data/execsql2_extras/inspect/make_demo.py +106 -0
  37. {execsql2-2.39.1.dist-info → execsql2-2.41.0.dist-info}/METADATA +84 -19
  38. {execsql2-2.39.1.dist-info → execsql2-2.41.0.dist-info}/RECORD +54 -47
  39. {execsql2-2.39.1.data → execsql2-2.41.0.data}/data/execsql2_extras/config_settings.sqlite +0 -0
  40. {execsql2-2.39.1.data → execsql2-2.41.0.data}/data/execsql2_extras/example_config_prompt.sql +0 -0
  41. {execsql2-2.39.1.data → execsql2-2.41.0.data}/data/execsql2_extras/make_config_db.sql +0 -0
  42. {execsql2-2.39.1.data → execsql2-2.41.0.data}/data/execsql2_extras/md_compare.sql +0 -0
  43. {execsql2-2.39.1.data → execsql2-2.41.0.data}/data/execsql2_extras/md_glossary.sql +0 -0
  44. {execsql2-2.39.1.data → execsql2-2.41.0.data}/data/execsql2_extras/md_upsert.sql +0 -0
  45. {execsql2-2.39.1.data → execsql2-2.41.0.data}/data/execsql2_extras/pg_compare.sql +0 -0
  46. {execsql2-2.39.1.data → execsql2-2.41.0.data}/data/execsql2_extras/pg_glossary.sql +0 -0
  47. {execsql2-2.39.1.data → execsql2-2.41.0.data}/data/execsql2_extras/script_template.sql +0 -0
  48. {execsql2-2.39.1.data → execsql2-2.41.0.data}/data/execsql2_extras/ss_compare.sql +0 -0
  49. {execsql2-2.39.1.data → execsql2-2.41.0.data}/data/execsql2_extras/ss_glossary.sql +0 -0
  50. {execsql2-2.39.1.data → execsql2-2.41.0.data}/data/execsql2_extras/ss_upsert.sql +0 -0
  51. {execsql2-2.39.1.dist-info → execsql2-2.41.0.dist-info}/WHEEL +0 -0
  52. {execsql2-2.39.1.dist-info → execsql2-2.41.0.dist-info}/entry_points.txt +0 -0
  53. {execsql2-2.39.1.dist-info → execsql2-2.41.0.dist-info}/licenses/LICENSE.txt +0 -0
  54. {execsql2-2.39.1.dist-info → execsql2-2.41.0.dist-info}/licenses/NOTICE +0 -0
@@ -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 _ast_only_stub(name: str):
89
- """Return an ErrInfo for a metacommand the AST executor handles structurally.
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=f"{name} should be handled by the AST executor, not the dispatch table.",
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 _ast_only_stub("IF")
105
+ raise unsupported_block_error("IF")
108
106
 
109
107
 
110
108
  def x_if_orif(**kwargs: Any) -> None:
111
- raise _ast_only_stub("ORIF")
109
+ raise unsupported_block_error("ORIF")
112
110
 
113
111
 
114
112
  def x_if_andif(**kwargs: Any) -> None:
115
- raise _ast_only_stub("ANDIF")
113
+ raise unsupported_block_error("ANDIF")
116
114
 
117
115
 
118
116
  def x_if_elseif(**kwargs: Any) -> None:
119
- raise _ast_only_stub("ELSEIF")
117
+ raise unsupported_block_error("ELSEIF")
120
118
 
121
119
 
122
120
  def x_if_else(**kwargs: Any) -> None:
123
- raise _ast_only_stub("ELSE")
121
+ raise unsupported_block_error("ELSE")
124
122
 
125
123
 
126
124
  def x_if_block(**kwargs: Any) -> None:
127
- raise _ast_only_stub("IF")
125
+ raise unsupported_block_error("IF")
128
126
 
129
127
 
130
128
  def x_if_end(**kwargs: Any) -> None:
131
- raise _ast_only_stub("ENDIF")
129
+ raise unsupported_block_error("ENDIF")
132
130
 
133
131
 
134
132
  def x_loop(**kwargs: Any) -> None:
135
- raise _ast_only_stub("LOOP")
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 _ast_only_stub("BEGIN BATCH")
192
+ raise unsupported_block_error("BEGIN BATCH")
195
193
 
196
194
 
197
195
  def x_end_batch(**kwargs: Any) -> None:
198
- raise _ast_only_stub("END BATCH")
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 _ast_only_stub("BREAK")
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.script.parser import metacommand_node
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(kwargs["cmd"].strip(), span))
81
+ block.body.append(metacommand_node(command, span))
78
82
 
79
83
 
80
84
  def x_extendscript_sql(**kwargs: Any) -> None: