execsql2 1.130.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/__init__.py +3 -0
- execsql/__main__.py +5 -0
- execsql/execsql.py +16627 -0
- execsql2-1.130.1.data/data/execsql2_extras/READ_ME.rst +129 -0
- execsql2-1.130.1.data/data/execsql2_extras/config_settings.sqlite +0 -0
- execsql2-1.130.1.data/data/execsql2_extras/example_config_prompt.sql +159 -0
- execsql2-1.130.1.data/data/execsql2_extras/execsql.conf +289 -0
- execsql2-1.130.1.data/data/execsql2_extras/make_config_db.sql +250 -0
- execsql2-1.130.1.data/data/execsql2_extras/md_compare.sql +630 -0
- execsql2-1.130.1.data/data/execsql2_extras/md_glossary.sql +327 -0
- execsql2-1.130.1.data/data/execsql2_extras/md_upsert.sql +2981 -0
- execsql2-1.130.1.data/data/execsql2_extras/pg_compare.sql +629 -0
- execsql2-1.130.1.data/data/execsql2_extras/pg_glossary.sql +291 -0
- execsql2-1.130.1.data/data/execsql2_extras/pg_upsert.sql +2792 -0
- execsql2-1.130.1.data/data/execsql2_extras/script_template.sql +300 -0
- execsql2-1.130.1.data/data/execsql2_extras/ss_compare.sql +639 -0
- execsql2-1.130.1.data/data/execsql2_extras/ss_glossary.sql +405 -0
- execsql2-1.130.1.data/data/execsql2_extras/ss_upsert.sql +2917 -0
- execsql2-1.130.1.dist-info/METADATA +418 -0
- execsql2-1.130.1.dist-info/RECORD +24 -0
- execsql2-1.130.1.dist-info/WHEEL +4 -0
- execsql2-1.130.1.dist-info/entry_points.txt +2 -0
- execsql2-1.130.1.dist-info/licenses/LICENSE.txt +12 -0
- execsql2-1.130.1.dist-info/licenses/NOTICE +10 -0
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
-- .sql
|
|
2
|
+
--
|
|
3
|
+
-- PURPOSE
|
|
4
|
+
--
|
|
5
|
+
--
|
|
6
|
+
-- NOTES
|
|
7
|
+
-- 1.
|
|
8
|
+
-- 2.
|
|
9
|
+
--
|
|
10
|
+
-- PROJECT
|
|
11
|
+
--
|
|
12
|
+
--
|
|
13
|
+
-- COPYRIGHT
|
|
14
|
+
-- Copyright (c) 202x,
|
|
15
|
+
--
|
|
16
|
+
-- AUTHORS
|
|
17
|
+
--
|
|
18
|
+
--
|
|
19
|
+
-- HISTORY
|
|
20
|
+
-- Date Remarks
|
|
21
|
+
-- ---------- -----------------------------------------------------------------
|
|
22
|
+
--
|
|
23
|
+
-- ==============================================================================
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
-- !x! if(False)
|
|
27
|
+
ERROR -- This script must be run using execsql.py;
|
|
28
|
+
-- !x! endif
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
-- ##############################################################################
|
|
32
|
+
-- Configuration
|
|
33
|
+
-- ==============================================================================
|
|
34
|
+
|
|
35
|
+
-- ------------------------------------------------------------------------------
|
|
36
|
+
-- General configuration
|
|
37
|
+
-- These settings ordinarily shouldn't need to be changed.
|
|
38
|
+
-- ------------------------------------------------------------------------------
|
|
39
|
+
-- !x! config make_export_dirs Yes
|
|
40
|
+
-- !x! config write_warnings Yes
|
|
41
|
+
-- !x! config console wait_when_done Yes
|
|
42
|
+
-- !x! config console wait_when_error Yes
|
|
43
|
+
|
|
44
|
+
-- !x! on cancel_halt execute script canceled
|
|
45
|
+
-- !x! on error_halt execute script crashed
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
-- ------------------------------------------------------------------------------
|
|
49
|
+
-- Script-specific configuration
|
|
50
|
+
-- These settings may need to be changed for some uses of the script.
|
|
51
|
+
-- ------------------------------------------------------------------------------
|
|
52
|
+
|
|
53
|
+
-- The "output_dir" variable will be set to a run-specific directory name that
|
|
54
|
+
-- is dynamically created and is different for each run of this script. The
|
|
55
|
+
-- run-specific output directories will be created underneath a parent directory.
|
|
56
|
+
-- The path to that parent directory is specified here. By default, the parent
|
|
57
|
+
-- directory is named "DB_output" and is under the current directory.
|
|
58
|
+
-- !x! sub output_parent DB_output
|
|
59
|
+
|
|
60
|
+
-- Create a unique number for every run, with corresponding output
|
|
61
|
+
-- directories and optionally a narrative descriptions.
|
|
62
|
+
-- !x! sub do_run_numbering True
|
|
63
|
+
-- Prompt for a run description?
|
|
64
|
+
-- !x! sub get_run_description True
|
|
65
|
+
|
|
66
|
+
-- Path to the SQL script library.
|
|
67
|
+
---- !x! sub script_library /path/to/sql/library
|
|
68
|
+
|
|
69
|
+
-- Change the base filename of the logfile as appropriate.
|
|
70
|
+
-- If run numbering is enabled, the logfile path and name that are set here
|
|
71
|
+
-- will be changed in the initialization section of this script.
|
|
72
|
+
-- !x! sub logfile logfiles/logfile_!!$date_tag!!.txt
|
|
73
|
+
|
|
74
|
+
-- Flag to control whether the custom logfile is rewritten each time.
|
|
75
|
+
-- If run numbering is enabled, this ordinarily will have no effect because
|
|
76
|
+
-- a new logfile will be created for each run.
|
|
77
|
+
-- !x! sub clean_logfile No
|
|
78
|
+
|
|
79
|
+
-- The actions to be carried out by this script; this information will be
|
|
80
|
+
-- included in documentation.
|
|
81
|
+
-- !x! sub script_purpose SCRIPT PURPOSE IS MISSING
|
|
82
|
+
-- The name of the person who requested this work.
|
|
83
|
+
-- !x! sub requested_by REQUESTOR NAME IS MISSING
|
|
84
|
+
-- The date that the request was made.
|
|
85
|
+
-- !x! sub request_date REQUEST DATE IS MISSING
|
|
86
|
+
-- Project number
|
|
87
|
+
-- !x! sub project_number PROJECT NUMBER IS MISSING
|
|
88
|
+
-- Additional metadata text that, if defined, will be included in the logfile prologue.
|
|
89
|
+
---- !x! sub metadata_comment
|
|
90
|
+
|
|
91
|
+
-- Define a user-specific staging schema. This prevents multiple users from
|
|
92
|
+
-- creating conflicting staging tables. Not all DBMSs support schemas.
|
|
93
|
+
-- !x! sub staging stg_!!$db_user!!
|
|
94
|
+
-- The current user must have permission to create a schema. Errors are
|
|
95
|
+
-- ignored because not all DBMSs support schemas.
|
|
96
|
+
-- !x! error_halt off
|
|
97
|
+
create schema if not exists !!staging!!;
|
|
98
|
+
-- !x! error_halt on
|
|
99
|
+
|
|
100
|
+
-- !x! if(not !!do_run_numbering!!)
|
|
101
|
+
-- Use an date-tagged directory name for "output_dir".
|
|
102
|
+
-- !x! sub output_dir !!output_parent!!!!$pathsep!!!!$date_tag!!
|
|
103
|
+
-- !x! endif
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
-- Allow settings from a custom configuration file, 'custom.conf',
|
|
107
|
+
-- to add to or replace configuration settings.
|
|
108
|
+
-- !x! if(file_exists(custom.conf)) {sub_ini custom.conf section execsql}
|
|
109
|
+
-- Any configuration file may define an additional section to read.
|
|
110
|
+
-- !x! if(sub_defined(additional_conf))
|
|
111
|
+
-- !x! sub_ini custom.conf section !!additional_conf!!
|
|
112
|
+
-- !x! endif
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
-- ------------------------------------------------------------------------------
|
|
116
|
+
-- Database-specific configuration
|
|
117
|
+
-- ------------------------------------------------------------------------------
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
-- ------------------------------------------------------------------------------
|
|
121
|
+
-- Dataset-specific configuration
|
|
122
|
+
-- ------------------------------------------------------------------------------
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
-- ------------------------------------------------------------------------------
|
|
126
|
+
-- ------------------------------------------------------------------------------
|
|
127
|
+
-- Run-specific configuration
|
|
128
|
+
-- ------------------------------------------------------------------------------
|
|
129
|
+
-- Flag to control the amount of information displayed.
|
|
130
|
+
-- !x! sub verbose Yes
|
|
131
|
+
|
|
132
|
+
-- Flag to control whether cleanup actions are carried out when the script finishes.
|
|
133
|
+
-- This may be set to "No" during development and testing, to assist with
|
|
134
|
+
-- diagnostics and debugging, and set to "Yes" for production uses.
|
|
135
|
+
-- Cleanu actions should be specified in the "cleanup" script at the end if this file.
|
|
136
|
+
-- !x! sub do_cleanup Yes
|
|
137
|
+
|
|
138
|
+
-- Flag to control whether transactions are to be committed.
|
|
139
|
+
-- !x! sub do_commit Yes
|
|
140
|
+
|
|
141
|
+
-- Flag to control execution of debugging code.
|
|
142
|
+
-- !x! sub do_debug No
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
-- ------------------------------------------------------------------------------
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
-- ##############################################################################
|
|
150
|
+
-- Library scripts to be used
|
|
151
|
+
-- ==============================================================================
|
|
152
|
+
|
|
153
|
+
-- For example:
|
|
154
|
+
---- !x! include !!script_library!!/pg_upsert.sql
|
|
155
|
+
|
|
156
|
+
-- ------------------------------------------------------------------------------
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
-- ##############################################################################
|
|
162
|
+
-- Initialization
|
|
163
|
+
-- ==============================================================================
|
|
164
|
+
|
|
165
|
+
-- ------------------------------------------------------------------------------
|
|
166
|
+
-- Set up the run number, get a run description, and save it.
|
|
167
|
+
-- A run number is always assigned, but it is used for the output directory
|
|
168
|
+
-- and logfile prefix only if the option is specified.
|
|
169
|
+
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
170
|
+
-- !x! if(file_exists(DB_run.conf))
|
|
171
|
+
-- !x! sub_ini file DB_run.conf section run
|
|
172
|
+
-- !x! endif
|
|
173
|
+
-- !x! if(not sub_defined(run_no))
|
|
174
|
+
-- !x! sub run_no 0
|
|
175
|
+
-- !x! endif
|
|
176
|
+
-- !x! sub_add run_no 1
|
|
177
|
+
-- !x! rm_file DB_run.conf
|
|
178
|
+
-- !x! write "# Automatically-generated database run number setting. Do not edit." to DB_run.conf
|
|
179
|
+
-- !x! write "[run]" to DB_run.conf
|
|
180
|
+
-- !x! write "run_no=!!run_no!!" to DB_run.conf
|
|
181
|
+
-- !x! sub run_tag !!run_no!!
|
|
182
|
+
-- !x! if(not is_gt(!!run_no!!, 9))
|
|
183
|
+
-- !x! sub run_tag 0!!run_tag!!
|
|
184
|
+
-- !x! endif
|
|
185
|
+
-- !x! if(not is_gt(!!run_no!!, 99))
|
|
186
|
+
-- !x! sub run_tag 0!!run_tag!!
|
|
187
|
+
-- !x! endif
|
|
188
|
+
-- !x! if(!!do_run_numbering!!)
|
|
189
|
+
-- !x! sub output_dir !!output_parent!!!!$pathsep!!Run_!!run_tag!!_!!$date_tag!!
|
|
190
|
+
-- !x! sub logfile logfiles!!$pathsep!!Run_!!run_tag!!_logfile.txt
|
|
191
|
+
-- !x! if(!!get_run_description!!)
|
|
192
|
+
-- !x! prompt enter_sub run_description message "Please enter a description for this run (!!run_tag!!)"
|
|
193
|
+
-- !x! if(not sub_empty(run_description))
|
|
194
|
+
-- !x! write "!!run_description!!" to !!output_dir!!!!$pathsep!!run_description.txt
|
|
195
|
+
-- !x! export query <<select !!run_no!! as "Run_no", '!!run_description!!' as "Description";>> append to DB_run_descriptions.csv as csv
|
|
196
|
+
-- !x! endif
|
|
197
|
+
-- !x! endif
|
|
198
|
+
-- !x! endif
|
|
199
|
+
-- ------------------------------------------------------------------------------
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
-- !x! console on
|
|
204
|
+
|
|
205
|
+
-- !x! if(!!clean_logfile!!) {rm_file !!logfile!!}
|
|
206
|
+
|
|
207
|
+
-- Write a prologue to the logfile.
|
|
208
|
+
-- !x! if(file_exists(!!logfile!!))
|
|
209
|
+
-- !x! write "" to !!logfile!!
|
|
210
|
+
-- !x! write "" to !!logfile!!
|
|
211
|
+
-- !x! endif
|
|
212
|
+
-- !x! write "==============================================================" to !!logfile!!
|
|
213
|
+
-- !x! if(sub_defined(script_purpose))
|
|
214
|
+
-- !x! write "!!script_purpose!!" tee to !!logfile!!
|
|
215
|
+
-- !x! write "--------------------------------------------------------------" to !!logfile!!
|
|
216
|
+
-- !x! write " " to !!logfile!!
|
|
217
|
+
-- !x! endif
|
|
218
|
+
-- !x! write "Requested by: !!requested_by!!" to !!logfile!!
|
|
219
|
+
-- !x! write "Reqested on: !!request_date!!" to !!logfile!!
|
|
220
|
+
-- !x! write "Project No.: !!project_number!!" to !!logfile!!
|
|
221
|
+
-- !x! write "Working dir: !!$CURRENT_DIR!!" to !!logfile!!
|
|
222
|
+
-- !x! write "Starting script: !!$STARTING_SCRIPT!!" to !!logfile!!
|
|
223
|
+
-- !x! write "Script rev time: !!$STARTING_SCRIPT_REVTIME!!" to !!logfile!!
|
|
224
|
+
-- !x! write "Current script: !!$CURRENT_SCRIPT!!" to !!logfile!!
|
|
225
|
+
-- !x! write "Database: !!$CURRENT_DATABASE!!" to !!logfile!!
|
|
226
|
+
-- !x! write "User: !!$DB_USER!!" to !!logfile!!
|
|
227
|
+
-- !x! write "Run at: !!$CURRENT_TIME!!" to !!logfile!!
|
|
228
|
+
-- !x! write "Run ID: !!$RUN_ID!!" to !!logfile!!
|
|
229
|
+
-- !x! write "Committing: !!do_commit!! to !!logfile!!
|
|
230
|
+
-- !x! write "Cleaning up: !!do_cleanup!! to !!logfile!!
|
|
231
|
+
-- !x! if(sub_defined(metadata_comment))
|
|
232
|
+
-- !x! write "" to !!logfile!!
|
|
233
|
+
-- !x! write "!!metadata_comment!!" to !!logfile!!
|
|
234
|
+
-- !x! endif
|
|
235
|
+
-- !x! write " " to !!logfile!!
|
|
236
|
+
|
|
237
|
+
-- ------------------------------------------------------------------------------
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
-- <The script body goes here.>
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
-- ------------------------------------------------------------------------------
|
|
251
|
+
|
|
252
|
+
-- ##############################################################################
|
|
253
|
+
-- Clean up and exit
|
|
254
|
+
-- ==============================================================================
|
|
255
|
+
-- !x! execute script cleanup
|
|
256
|
+
|
|
257
|
+
-- !x! write "" tee to !!logfile!!
|
|
258
|
+
-- !x! write "Done." tee to !!logfile!!
|
|
259
|
+
-- !x! write "--------------------------------------------------------------" tee to !!logfile!!
|
|
260
|
+
-- !x! write "" to !!logfile!!
|
|
261
|
+
-- !x! write "" to !!logfile!!
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
-- No SQL statements or metacommands should be below this point, only scripts and comments.
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
-- ##############################################################################
|
|
269
|
+
-- Scripts
|
|
270
|
+
-- ==============================================================================
|
|
271
|
+
|
|
272
|
+
-- !x! begin script cleanup
|
|
273
|
+
-- !x! if(!!do_cleanup!!)
|
|
274
|
+
-- !x! write ""
|
|
275
|
+
-- !x! write "Cleaning up."
|
|
276
|
+
-- <Script-specific cleanup steps go here>
|
|
277
|
+
-- <or they may be appended using an EXTEND SCRIPT metacommand.>
|
|
278
|
+
-- !x! write "" to !!logfile!!
|
|
279
|
+
-- !x! endif
|
|
280
|
+
-- !x! end script cleanup
|
|
281
|
+
|
|
282
|
+
-- !x! begin script canceled
|
|
283
|
+
-- !x! write "" tee to !!logfile!!
|
|
284
|
+
-- !x! write "Script canceled by user." tee to !!logfile!!
|
|
285
|
+
-- !x! execute script cleanup
|
|
286
|
+
-- !x! write "" to !!logfile!!
|
|
287
|
+
-- !x! end script canceled
|
|
288
|
+
|
|
289
|
+
-- !x! begin script crashed
|
|
290
|
+
-- !x! write "" tee to !!logfile!!
|
|
291
|
+
-- !x! write "Script halted by an error." tee to !!logfile!!
|
|
292
|
+
-- !x! execute script cleanup
|
|
293
|
+
-- !x! write "" to !!logfile!!
|
|
294
|
+
-- !x! end script crashed
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
--
|
|
298
|
+
-- End of script_template.sql
|
|
299
|
+
--
|
|
300
|
+
|