Zymonic Toolkit System: Difference between revisions

From Zymonic
Content added Content deleted
(Created page with "==Synchronize_csv== Command general info This is a new toolkit command which replaces “upload_csv” called “synchronize_csv”. New command can be used to relatively q...")
 
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
This page contains all of the options for:
==Synchronize_csv==
<pre>
sudo zymonic_toolkit.pl System
</pre>


See the [https://mq2-public.zednax.com/man/ztsm/Toolkit/System.html manual page for the system toolkit] for further details.
Command general info


=Synchronize CSV=
This is a new toolkit command which replaces “upload_csv” called “synchronize_csv”. New command can be used to relatively quickly: insert, update, update/insert and delete records in a Zymonic table based on a csv. Usage is as follows.
This command can be used to relatively quickly: insert, update, update/insert and delete records in a Zymonic table based on a csv. Usage is as follows.
<pre>
sudo zymonic_toolkit.pl System synchronize_csv [PARAMETERS]
</pre>
==Example==
Command to run:
<pre>
sudo zymonic_toolkit.pl System synchronize_csv --system test_system --table_zname zz_countrylist --field_sequence "country,alpha2code,alpha3code,countrycode,countryintdial,currencycode" --update_type "UpdateOrInsert" --username admin --zpass ! --csv_path "/tmp/country.csv"
</pre>
Data in `/tmp/country.csv`:
<pre>
United Kingdom of Great Britain and Northern Ireland,GB,GBR,826,44,GBP
</pre>
==Parameters==
<table style="width:100%">
<tr>
<th>Parameter Name</th>
<th>Parameter Description</th>
</tr>
<tr>
<th colspan="2">Required Parameters</th>
</tr>
<tr align="left">
<td>system</td>
<td>The name of the sub-directory in which the system's definition is stored.</td>
</tr>
<tr align="left">
<td>table_zname</td>
<td>ZName of the table to be imported into.</td>
</tr>
<tr align="left">
<td>field_sequence</td>
<td>Comma seperated sequence of ZNames in the order they are represented in the csv file.</td>
</tr>
<tr align="left">
<td>username</td>
<td>The username of the user (defaults to admin).</td>
</tr>
<tr>
<th colspan="2">Optional Parameters</th>
</tr>
<tr align="left">
<td>csv_path</td>
<td>Path to the csv to be used.</td>
</tr>
<tr align="left">
<td>csv_string</td>
<td>CSV data a comma delimited string, new lines with \n. CSV file will be created in tmp and then read.</td>
</tr>
<tr align="left">
<td>zpass</td>
<td>The password of the user to run tests as, use ! to enter at run time.</td>
</tr>
<tr align="left">
<td>state</td>
<td>ZName of the state to save the records in. Records edited in the GUI will then open a process in this state.</td>
</tr>
<tr align="left">
<td>blank_is_undef</td>
<td>Set to false to have blank values in the csv sent through as empty string, overwriting default values.</td>
</tr>
<tr align="left">
<td>update_type</td>
<td>Defaults to “Insert”. You can select the type of update to do from the types described below this table.
</tr>
<tr align="left">
<td>keyfields</td>
<td>Unique field(s) used to identify records to update/delete. Not needed for Insert.</td>
</tr>
<tr align="left">
<td>delete_others</td>
<td>Flag to delete records in the destination table not found in the csv. Defaults to no.</td>
</tr>
<tr align="left">
<td>batch_size</td>
<td>Defaults to 100. Varies the size batch that the code passes the data through in internally only changes performance, 100 was found to be a good number.</td>
</tr>
<tr align="left">
<td>multiple_records_mode</td>
<td>When there are duplicate records matched but duplicates are not allowed, keep the newest records "n" or the oldest "o".</td>
</tr>
<tr align="left">
<td>allow_duplicate_records</td>
<td>Allow the update of duplicate records. If false, duplicates will be deleted according to multiple_records_mode option.</td>
</tr>
<tr align="left">
<td>hard_delete</td>
<td>Set to true to remove deleted records from the database. If this option is not set any records, to be deleted, will be marked as deleted: Y in the database.</td>
</tr>
<tr align="left">
<td>process_zname</td>
<td>ZName of the process to associate with the uploaded records, this will then be the process opened when editing the record in the GUI. Defaults to the default process of the table.</td>
</tr>
</table>
==Update Types==
===Insert===
Insert any data from the csv file into the specified table including any duplicates. Data should be in the same order as the field sequence specified, keyfields are ignored.


===Update===
Update any matching data from the csv file in the specified table. Data should be in the same order as the field sequence specified, keyfields are used in combination to identify the correct records. By default duplicate records in the table will be set as deleted. No action will be taken if the records aren't found in the table.


===Delete===
Usage
Delete any records from the csv file in the specified table. Data should be in the same order as the field sequence specified, keyfields are used in combination to identify the correct records. Option hard_delete can be used to remove the records from the table completely instead of just marking them as deleted in the DB.


===UpdateOrInsert===
Update any matching data from the csv file in the specified table, and insert non-matching records. Data should be in the same order as the field sequence specified, keyfields are used in combination to identify the correct records. By default duplicate records in the table will be set as deleted.


===InsertIfNotFound===
sudo zymonic_toolkit.pl System synchronize_csv [parameters below]
Insert any data from the csv file into the specified table unless the data is already in the table. Data should be in the same order as the field sequence specified, keyfields are used in combination to identify the correct records.




=Get System Option=
Required parameters
This command returns the value of a system option for a given system and option name.


<pre>
--system - System the destination table is in
sudo zymonic_toolkit.pl System get_sys_opt [PARAMETERS]
--table_zname - ZName of destination table to be altered
</pre>
--field_sequence - Comma delimited list of field znames in the order the data appears in the csv
==Example==
--csv_path - File path to the csv file with the data
--username - Username for the systems GUI
--zpass - Corresponding password for the username


sudo zymonic_toolkit.pl System get_sys_opt --system test_system --option filter_report_max_results

Optional parameters:

--state - State to set the inserted records to for the GUI. Most likely should be the state saved records are set to.
--keyfields - Comma delimited list of fields to be used to match existing records in the table when updating/deleting. May be primary key, or a list of fields which combined are unique. Not needed for Insert.
--delete_others - Defaults to no. If set to “yes”, will set records from the table which aren’t in the csv file as deleted.
--update_type Defaults to “Insert”. Mode to run the command in options:
-Insert - insert records from the csv as long as they pass validation
-Update – update records in the table matching the csv based on the keyfields supplied
-UpdateOrInsert – updates matching records, inserts others
-Delete – delete records in table matching csv
--batch_size - Defaults to 100. Varies the size batch that the code passes the data through in internally only changes performance, 100 was found to be a good number.

Latest revision as of 15:10, 11 June 2020

This page contains all of the options for:

sudo zymonic_toolkit.pl System

See the manual page for the system toolkit for further details.

Synchronize CSV[edit]

This command can be used to relatively quickly: insert, update, update/insert and delete records in a Zymonic table based on a csv. Usage is as follows.

sudo zymonic_toolkit.pl System synchronize_csv [PARAMETERS]

Example[edit]

Command to run:

sudo zymonic_toolkit.pl System synchronize_csv --system test_system --table_zname zz_countrylist --field_sequence "country,alpha2code,alpha3code,countrycode,countryintdial,currencycode" --update_type "UpdateOrInsert" --username admin --zpass ! --csv_path "/tmp/country.csv"

Data in `/tmp/country.csv`:

United Kingdom of Great Britain and Northern Ireland,GB,GBR,826,44,GBP

Parameters[edit]

Parameter Name Parameter Description
Required Parameters
system The name of the sub-directory in which the system's definition is stored.
table_zname ZName of the table to be imported into.
field_sequence Comma seperated sequence of ZNames in the order they are represented in the csv file.
username The username of the user (defaults to admin).
Optional Parameters
csv_path Path to the csv to be used.
csv_string CSV data a comma delimited string, new lines with \n. CSV file will be created in tmp and then read.
zpass The password of the user to run tests as, use ! to enter at run time.
state ZName of the state to save the records in. Records edited in the GUI will then open a process in this state.
blank_is_undef Set to false to have blank values in the csv sent through as empty string, overwriting default values.
update_type Defaults to “Insert”. You can select the type of update to do from the types described below this table.
keyfields Unique field(s) used to identify records to update/delete. Not needed for Insert.
delete_others Flag to delete records in the destination table not found in the csv. Defaults to no.
batch_size Defaults to 100. Varies the size batch that the code passes the data through in internally only changes performance, 100 was found to be a good number.
multiple_records_mode When there are duplicate records matched but duplicates are not allowed, keep the newest records "n" or the oldest "o".
allow_duplicate_records Allow the update of duplicate records. If false, duplicates will be deleted according to multiple_records_mode option.
hard_delete Set to true to remove deleted records from the database. If this option is not set any records, to be deleted, will be marked as deleted: Y in the database.
process_zname ZName of the process to associate with the uploaded records, this will then be the process opened when editing the record in the GUI. Defaults to the default process of the table.

Update Types[edit]

Insert[edit]

Insert any data from the csv file into the specified table including any duplicates. Data should be in the same order as the field sequence specified, keyfields are ignored.

Update[edit]

Update any matching data from the csv file in the specified table. Data should be in the same order as the field sequence specified, keyfields are used in combination to identify the correct records. By default duplicate records in the table will be set as deleted. No action will be taken if the records aren't found in the table.

Delete[edit]

Delete any records from the csv file in the specified table. Data should be in the same order as the field sequence specified, keyfields are used in combination to identify the correct records. Option hard_delete can be used to remove the records from the table completely instead of just marking them as deleted in the DB.

UpdateOrInsert[edit]

Update any matching data from the csv file in the specified table, and insert non-matching records. Data should be in the same order as the field sequence specified, keyfields are used in combination to identify the correct records. By default duplicate records in the table will be set as deleted.

InsertIfNotFound[edit]

Insert any data from the csv file into the specified table unless the data is already in the table. Data should be in the same order as the field sequence specified, keyfields are used in combination to identify the correct records.


Get System Option[edit]

This command returns the value of a system option for a given system and option name.

sudo zymonic_toolkit.pl System get_sys_opt [PARAMETERS]

Example[edit]

sudo zymonic_toolkit.pl System get_sys_opt --system test_system --option filter_report_max_results