Zymonic Toolkit System: Difference between revisions

From Zymonic
Content added Content deleted
(Tidied article to make parameters clearer.)
(Added extra options and tidied)
Line 1: Line 1:
This page contains all of the options for:
==Synchronize_csv==
<pre>

sudo zymonic_toolkit.pl System
Command general info
</pre>

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.


Usage


sudo zymonic_toolkit.pl System synchronize_csv [parameters below]


=Synchronize CSV=
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>
==Parameters==
<table style="width:100%">
<table style="width:100%">
<tr>
<th colspan="2">Required Parameters</th>
</tr>
<tr>
<tr>
<th>Parameter Name</th>
<th>Parameter Name</th>
<th>Parameter Description</th>
<th>Parameter Description</th>
</tr>
<tr>
<th colspan="2">Required Parameters</th>
</tr>
</tr>
<tr align="left">
<tr align="left">
<td>system</td>
<td>system</td>
<td>System the destination table is in</td>
<td>The name of the sub-directory in which the system's definition is stored.</td>
</tr>
</tr>
<tr align="left">
<tr align="left">
<td>table_zname</td>
<td>table_zname</td>
<td>ZName of destination table to be altered</td>
<td>ZName of the table to be imported into.</td>
</tr>
</tr>
<tr align="left">
<tr align="left">
<td>field_sequence</td>
<td>field_sequence</td>
<td>Comma delimited list of field znames in the order the data appears in the csv</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>
<tr align="left">
<tr align="left">
<td>csv_path</td>
<td>csv_path</td>
<td>File path to the csv file with the data</td>
<td>Path to the csv to be used.</td>
</tr>
</tr>
<tr align="left">
<tr align="left">
<td>username</td>
<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>
<td>Username for the systems GUI</td>
</tr>
</tr>
<tr align="left">
<tr align="left">
<td>zpass</td>
<td>zpass</td>
<td>Corresponding password for the username</td>
<td>The password of the user to run tests as, use ! to enter at run time.</td>
</tr>
</tr>
<tr>
<tr align="left">
<th colspan="2">Optional Parameters</th>
<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>
<tr>
<tr align="left">
<th>Parameter Name</th>
<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>
<th>Parameter Description</th>
</tr>
</tr>
<tr align="left">
<tr align="left">
<td>state</td>
<td>update_type</td>
<td>State to set the inserted records to for the GUI. Most likely should be the state saved records are set to.</td>
<td>Defaults to “Insert”. You can select the type of update to do from the types described below this table.
</tr>
</tr>
<tr align="left">
<tr align="left">
<td>keyfields</td>
<td>keyfields</td>
<td>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.</td>
<td>Unique field(s) used to identify records to update/delete. Not needed for Insert.</td>
</tr>
</tr>
<tr align="left">
<tr align="left">
<td>delete_others</td>
<td>delete_others</td>
<td>Defaults to no. If set to “yes”, will set records from the table which aren’t in the csv file as deleted.</td>
<td>Flag to delete records in the destination table not found in the csv. Defaults to no.</td>
</tr>
<tr align="left">
<td>update_type</td>
<td>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</td>
</tr>
</tr>
<tr align="left">
<tr align="left">
<td>batch_size</td>
<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>
<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>
</tr>
</table>
</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===
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===
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.

Revision as of 13:26, 27 May 2020

This page contains all of the options for:

sudo zymonic_toolkit.pl System

Synchronize CSV

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]

Parameters

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

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

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

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.