• R/O
  • SSH

execsql: Commit

Default repository for execsql.py


Commit MetaInfo

Revisãoe8db761fb48fbe89025561edefa5ca12bf64fa00 (tree)
Hora2020-02-23 04:12:13
AutorDreas Nielsen <dreas.nielsen@gmai...>
CommiterDreas Nielsen

Mensagem de Log

Added EXTEND SCRIPT metacommands for SQL statements, metacommands, and scripts.

Mudança Sumário

Diff

diff -r 61718d639611 -r e8db761fb48f CHANGELOG.rst
--- a/CHANGELOG.rst Sat Feb 22 09:52:26 2020 -0800
+++ b/CHANGELOG.rst Sat Feb 22 11:12:13 2020 -0800
@@ -1,6 +1,7 @@
11 ========== ========== =================================================================================
22 Version Date Features
33 ========== ========== =================================================================================
4+1.67.0 2020-02-22 Added the EXTEND SCRIPT WITH SQL and EXTEND SCRIPT WITH METACOMMAND metacommands, and aliased the APPEND SCRIPT metacommand to EXTEND SCRIPT...WITH SCRIPT.
45 1.66.0 2020-02-22 Added the DISCONNECT metacommand.
56 1.65.0 2020-02-22 Added CONFIG SCAN_LINES and CONFIG GUI_LEVEL metacommands.
67 1.64.0 2020-02-22 Added the LOCAL and USER keywords to the DEBUG LOG CONFIG metacommand.
diff -r 61718d639611 -r e8db761fb48f doc/source/conf.py
--- a/doc/source/conf.py Sat Feb 22 09:52:26 2020 -0800
+++ b/doc/source/conf.py Sat Feb 22 11:12:13 2020 -0800
@@ -58,9 +58,9 @@
5858 # built documents.
5959 #
6060 # The short X.Y version.
61-version = u'1.66'
61+version = u'1.67'
6262 # The full version, including alpha/beta/rc tags.
63-release = u'1.66'
63+release = u'1.67'
6464
6565 # A string of reStructuredText that will be included at the beginning of
6666 # every source file that is read.
diff -r 61718d639611 -r e8db761fb48f doc/source/metacommands.rst
--- a/doc/source/metacommands.rst Sat Feb 22 09:52:26 2020 -0800
+++ b/doc/source/metacommands.rst Sat Feb 22 11:12:13 2020 -0800
@@ -1775,6 +1775,38 @@
17751775 EXTEND SCRIPT
17761776 -----------------------------------------
17771777
1778+Several forms of the EXTEND SCRIPT metacommand allow a script that has
1779+previously been created with the :ref:`BEGIN SCRIPT <beginscript>`
1780+metacommand to be modified by the addition of more commands.
1781+
1782+This may be useful, for example, if a cleanup script is named in an
1783+:ref:`ON ERROR_HALT EXECUTE SCRIPT <error_halt_exec>` or
1784+:ref:`ON CANCEL_HALT EXECUTE SCRIPT <cancel_halt_exec>` metacommand, and
1785+additional steps should later be added to the cleanup script based on
1786+actions taken in the main script.
1787+
1788+::
1789+
1790+ EXTEND SCRIPT <script> WITH SQL <sql_statement>
1791+
1792+Appends the SQL statement to the end of the specified script.
1793+Substitution variables will be evaluated twice: once when the
1794+EXTEND SCRIPT metacommand is run, and a second time when the SQL
1795+statement itself is run. :ref:`Deferred substitution <deferred_substitution>`
1796+may be needed to ensure that some substitution variables are
1797+replaced when the SQL statement is run.
1798+
1799+::
1800+
1801+ EXTEND SCRIPT <script> WITH METACOMMAND <metacommand>
1802+
1803+Appends the metacommand statement to the end of the specified script.
1804+Substitution variables will be evaluated twice: once when the
1805+EXTEND SCRIPT metacommand is run, and a second time when the metacommand
1806+statement itself is run. :ref:`Deferred substitution <deferred_substitution>`
1807+may be needed to ensure that some substitution variables are
1808+replaced when the metacommand is run.
1809+
17781810 ::
17791811
17801812 EXTEND SCRIPT <script_1> WITH SCRIPT <script_2>
@@ -1784,11 +1816,6 @@
17841816 :ref:`BEGIN SCRIPT <beginscript>` metacommand. Parameters for *script_2*
17851817 are also added to *script_1*.
17861818
1787-If a cleanup script is named in an
1788-:ref:`ON ERROR_HALT EXECUTE SCRIPT <error_halt_exec>` or
1789-:ref:`ON CANCEL_HALT EXECUTE SCRIPT <cancel_halt_exec>` metacommand, the
1790-APPEND SCRIPT metacommand allows the cleanup script to be extended as
1791-appropriate.
17921819
17931820
17941821
diff -r 61718d639611 -r e8db761fb48f doc/source/substitution_vars.rst
--- a/doc/source/substitution_vars.rst Sat Feb 22 09:52:26 2020 -0800
+++ b/doc/source/substitution_vars.rst Sat Feb 22 11:12:13 2020 -0800
@@ -637,7 +637,8 @@
637637 ------------------------------------
638638
639639 The ON ERROR_HALT metacommands, the ON CANCEL_HALT metacommands, the
640-EXECUTE SCRIPT WHILE/UNTIL metacommands, and the LOOP metacommand
640+EXECUTE SCRIPT WHILE/UNTIL metacommands, the LOOP metacommand, and
641+two forms of the EXTEND SCRIPT metacommand
641642 all accept clauses or arguments that can contain substitution variables
642643 that are meant to be evaluated after the execution of the metacommand
643644 itself. For example, in the metacommand line::
@@ -658,6 +659,4 @@
658659
659660 ON ERROR_HALT WRITE "Error in line: !{$LAST_ERROR}!"
660661
661-Deferred substitution may also be of use in some other circumstances,
662-such as arguments used with the :ref:`EXECUTE SCRIPT <executescript>` metacommand.
663662
diff -r 61718d639611 -r e8db761fb48f execsql/execsql.py
--- a/execsql/execsql.py Sat Feb 22 09:52:26 2020 -0800
+++ b/execsql/execsql.py Sat Feb 22 11:12:13 2020 -0800
@@ -27,12 +27,12 @@
2727 #
2828 # ===============================================================================
2929
30-__version__ = "1.66.1"
30+__version__ = "1.67.0"
3131 __vdate = "2020-02-22"
3232
3333 primary_vno = 1
34-secondary_vno = 66
35-tertiary_vno = 1
34+secondary_vno = 67
35+tertiary_vno = 0
3636
3737 import os
3838 import os.path
@@ -10031,6 +10031,29 @@
1003110031
1003210032
1003310033
10034+#**** EXTEND SCRIPT WITH SQL
10035+def x_extendscript_sql(**kwargs):
10036+ script = kwargs["script"].lower()
10037+ if script not in savedscripts:
10038+ raise ErrInfo("cmd", other_msg="There is no SCRIPT named %s." % script)
10039+ sql = kwargs["sql"]
10040+ savedscripts[script].add(SqlStmt(kwargs["sql"]))
10041+
10042+metacommands.append(MetaCommand(r'\s*EXTEND\s+SCRIPT\s+(?P<script>\w+)\s+WITH\s+SQL\s+(?P<sql>.+)\s*$', x_extendscript_sql))
10043+
10044+
10045+
10046+#**** EXTEND SCRIPT WITH METACOMMAND
10047+def x_extendscript_metacommand(**kwargs):
10048+ script = kwargs["script"].lower()
10049+ if script not in savedscripts:
10050+ raise ErrInfo("cmd", other_msg="There is no SCRIPT named %s." % script)
10051+ savedscripts[script].add(MetacommandStmt(kwargs["cmd"]))
10052+
10053+metacommands.append(MetaCommand(r'\s*EXTEND\s+SCRIPT\s+(?P<script>\w+)\s+WITH\s+METACOMMAND\s+(?P<cmd>.+)\s*$', x_extendscript_metacommand))
10054+
10055+
10056+
1003410057 #**** EXECUTE SCRIPT
1003510058 def x_executescript(**kwargs):
1003610059 ScriptExecSpec(**kwargs).execute()
diff -r 61718d639611 -r e8db761fb48f setup.py
--- a/setup.py Sat Feb 22 09:52:26 2020 -0800
+++ b/setup.py Sat Feb 22 11:12:13 2020 -0800
@@ -4,7 +4,7 @@
44 long_description = f.read()
55
66 setuptools.setup(name='execsql',
7- version='1.66.0',
7+ version='1.67.0',
88 description="Runs a SQL script against a PostgreSQL, MS-Access, SQLite, MS-SQL-Server, MySQL, MariaDB, Firebird, 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. Data can be exported in 13 different formats, including CSV, TSV, ODS, HTML, JSON, LaTeX, and Markdown tables, and using custom templates.",
99 author='Dreas Nielsen',
1010 author_email='dreas.nielsen@gmail.com',
Show on old repository browser