Activities
- Connect to MySQL
- Disconnect from MySQL
- Add User Access to Database
- Backup Database
- Delete Row(s) from Table
- Insert Row(s) into Table
- Remove User Access from Database
- Restore Database
- Run Query
- Select Row(s) from Table
- Export from Database
- Import into Database
Connect to MySQL
This activity connects to a MySQL Host. The Output of this activity should be used as input for all Connection parameters used for activities placed under MySQL category.
Activity Parameters
The Connect to MySQL activity parameters can be provided by manual inserted values or via IN arguments or variables:
Parameters:
- Database (text box editor type) (type: string): the database name to connect to, in this example "FlowsterMySQLActivities".
- Password (password editor type) (type: string): the password for the provided username. In the example from the screenshot there is used the user root with no password, which leads to a blank Password field.
- Password Binding (text box editor type) (type: string): bind to a variable containing the encrypted password for the sql server. (This parameter is used only when the user wants to send an encrypted password from outside the workflow, for example Flowster Portal).
- Port (text box editor type) (type: int32): the port number.
- Server Name (text box editor type) (type: string): the name or IP of the MySQL Server to connect to.
- Username (text box editor type) (type: string): the the username of the MySQL Server Administrator. In our example, user root is used.
The Read Only Output variable are the possible output values that the activity will provide:
- Connection (type: object): outputs a SQL connection. The Output of this activity should be used as input for all Connection parameters used for activities placed under MySQL category.
Disconnect from MySQL
This activity disconnects from a MySQL Host.
Activity Parameters
The Disconnect from MySQL activity parameters can be provided by manual inserted values or via IN arguments or variables:
Parameters:
- Connection (text box editor type) (type: object): the output from a Connect to MySQL activity.
Add User Access to Database
This activity adds privileges for an user to a database.
Activity Parameters
The Add User Access to Database activity parameters can be provided by manual inserted values or via IN arguments or variables:
Parameters:
- Host Name (value selector list) (type: string): the hostname that the user can connect from. In this case localhost will be used, so that the user can connect to MySQL Admin from the same machine where the server is installed.
- Username for Access (text box editor type) (type: string): the name of the user that will receive permissions.
The Read Only Output variable are the possible output values that the activity will provide:
- Output (type: boolean): outputs True or False if the execution was successful or not.
Execution: the activity will search if the user already exists in the user table from the mysql database (MySQL system database). If found, it will grant access to the database where the activity is connected:
Backup Database
This activity creates an .sql file backup for the selected database.
Activity Parameters
The Backup Database activity parameters can be provided by manual inserted values or via IN arguments or variables:
Parameters:
- Backup Path (text box editor type) (type: string): the path where the backup file will be created.
- File Name (text box editor type) (type: string): the name of the backup file that will be created. Should be an .sql extension file (E.G. FlowsterMySQLActivities.sql, where the file name is the same with the database's).
- MySQLDump.exe Path (text box editor type) (type: string): the path of the mysqldump.exe, or select it with the File Browser. If using XAMPP, the default path is C:\xampp\mysql\bin\mysqldump.exe.
- Password (password editor type) (type: string): the password for the provided username.
- Password Binding (text box editor type) (type: string): bind to a variable containing the encrypted password for the sql server. (This parameter is used only when the user wants to send an encrypted password from outside the workflow, for example Flowster Portal).
The Read Only Output variable are the possible output values that the activity will provide:
- Output (type: string): outputs the path of the backup file.
Delete Row(s) from Table
This activity deletes Row(s) from a SQL Server database table.
Activity Parameters
The Delete Row(s) from Table activity parameters can be provided by manual inserted values or via IN arguments or variables:
Parameters:
- Table (text box editor type) (type: string): the table name where the row(s) will be deleted.
- Where Statement (text box editor type) (type: string): the Where statement to filter the row(s) that will be deleted. For example: ID>2, where all rows with an ID higher than 2 will be deleted.
Execution: the activity will delete all the rows from a table according to the given Where statement:
- the initial table content:
- the table content after deletion:
Insert Row(s) into Table
This activity inserts Row(s) on a MySQL Server database table.
Activity Parameters
The Insert Row(s) into Table activity parameters can be provided by manual inserted values or via IN arguments or variables:
Parameters:
- Fields (text box editor type) (type: string): the column headers that you want to insert the new values in. If you enter more than one you should separate them with ','. For example: Name,Surname,Company.
- Table (text box editor type) (type: string): the table name where the row(s) will be inserted.
- Values (text box editor type) (type: string): the values for specified fields in Fields parameter. If you enter more than one you should separate them with ','. If you have more values each should be placed in the same order as you add the fields.For example: May,James,Amazon Prime.
The Read Only Output variable are the possible output values that the activity will provide:
- Output Last ID (type: string): outputs the last row inserted ID.
Execution: the activity will insert the new row into the selected table and will output the ID of the added row. In the database, the row can be seen at the last position:
Remove User Access from Database
This activity removes privileges for an user to a database.
Activity Parameters
The Remove User Access from Database activity parameters can be provided by manual inserted values or via IN arguments or variables:
Parameters:
- Username to be Removed (text box editor type) (type: string): the name of the user that will have denied permissions.
The Read Only Output variable are the possible output values that the activity will provide:
- Output (type: boolean): outputs True or False if the execution was successful or not.
Restore Database
This activity restores a Database from a backup .sql file.
Activity Parameters
The Restore Database activity parameters can be provided by manual inserted values or via IN arguments or variables:
Parameters:
- Backup File Path (text box editor type) (type: string): the path of the backup file or select it with the File Browser. The .sql file path can be manually written or selected by clicking the button. In this example the backup file has the same name as the database's.
- MySQL.exe Path (text box editor type) (type: string): the path of the mysql.exe, or select it with the File Browser. If using XAMPP, the default path is C:\xampp\mysql\mysql.exe.
- Password (password editor type) (type: string): the password for the provided username.
- Password Binding (text box editor type) (type: string): bind to a variable containing the encrypted password for the sql server. (This parameter is used only when the user wants to send an encrypted password from outside the workflow, for example Flowster Portal).
The Read Only Output variable are the possible output values that the activity will provide:
- Output (type: boolean): outputs True or False if the execution was successful or not.
Run query
This activity runs a query on a SQL Server database.
Activity Parameters
The Run Query activity parameters can be provided by manual inserted values or via IN arguments or variables:
Parameters:
- Query (text box editor type) (type: string): the SQL query string. For example: "SELECT Name, Company FROM Names where ID>1 and ID<4 order by name ASC"
- Script (text box editor type) (type: string): the query content if a binding to a variable is used ($using). If set and if the $using:variable syntax is used, this parameter will take precedence over the Query parameter. For example, the $using:DemoString syntax will take the value stored in the DemoString variable and will execute it:
The Read Only Output variable are the possible output values that the activity will provide:
- Output (type: collection<collection<string>>): outputs a collection of returned rows.To use the elements of the collection, use ForEachFactory activity.
- Output Columns (type: int32): outputs the number of columns returned.
- Output Rows (type: int32): outputs the number of rows returned.
Execution: In the Tracking Data there can be seen the returned results:
The same result can be seen when executing the same SQL Select query from PHPMyAdmin:
Select Row(s) from Table
This activity selects and returns Row(s) from a SQL Server database table.
Activity Parameters
The Select Row(s) from Table activity parameters can be provided by manual inserted values or via IN arguments or variables:
Parameters:
- Distinct (combo box control) (type: string): whether the returned values should be distinct or not.
- Fields (text box editor type) (type: string): the column headers that you want to be returned with the select command. If you enter more than one you should separate them with ','. If all fields needs to be returned, then just use "*". The " * " has the same role as used in the SQL select all statement: select * from table
- Limit (text box editor type) (type: string): limit the number of results. If the field is left blank, then the activity will return all the rows from the table
- Order By (text box editor type) (type: string): the column header that you want to result to be ordered by. For example, if "ID" is inserted, then the values returned will be ordered depending on the value set in the ID column. If no value is provided, the activity will return the values in the same order as taken from the table.
- Order by Direction (combo box control) (type: string): choose to order the resulted rows in Ascending or Descending direction. It will be ignored if Order By is not set.
- Table (text box editor type) (type: string): the table name on which to run the select.
- WHERE (text box editor type) (type: string): the Where statement. For example: ID>2, where ID is a column header.
The Read Only Output variable are the possible output values that the activity will provide:
- Output (type: collection<collection<string>>): outputs a collection of collections of strings containing the selected rows.To use the elements of the collection, use Get Element From Collection activity.
- Output Columns (type: int32): outputs the number of columns returned.
- Output Rows (type: int32): outputs the number of rows returned.
A more complex example, with fields, orders and statements can be seen in the image below:
Execution: In the Tracking Data there can be seen the returned results:
The same result can be seen when executing the same SQL Select query from PHPMyAdmin:
Export from Database
This activity exports data from a Database into an XML or a CSV file.
Activity Parameters
The Export from Database activity parameters can be provided by manual inserted values or via IN arguments or variables:
Parameters:
- Destination Path (combo box control) (type: string): the path where the export (csv or xml) file will be created.
- File Name (text box editor type) (type: string): the name of the XML file or CSV file that will be created. E.g. 'MySQLTableExport'.
- File Type (combo box control) (type: string): the type of the file that will be created. For each of them a different set of parameters will be displayed.
- Overwrite (combo box control) (type: string): whether to overwrite the file if it already exists.
- Root Name (text box editor type) (type: string): the name of the root for the .xml file. This field should be completed only when XML is selected in the File Type field. As syntax, for example, xml_root can be used.
- Table (text box editor type) (type: string): the table(s) from where the export will be made (accepts multiple values separated by comma).
The Read Only Output variable are the possible output values that the activity will provide:
- Output (type: boolean): outputs True or False if the execution was successful or not.
Execution: the activity will create an export file of the table(s) settled in the Table field, in the specified folder:
Import into Database
This activity imports data into a Database from an XML or a CSV file.
Activity Parameters
The Import into Database activity parameters can be provided by manual inserted values or via IN arguments or variables:
Parameters:
- File Type (combo box control) (type: string): the type of the file that will be imported from. Flowster Studio provides by default CSV and XML types.
- First Row Header (combo box control) (type: string): whether the CSV file includes the header as a first row or not. If, for example, it is used a CSV file obtained via the Export From Database activity, then leave True for this parameter (the Export From Database activity also exports the column names on the first row of the file).
- Import File Path (text box editor type) (type: string): the path where the file will be selected from, or choose it with the file browser, by clicking the button.
- Table (text box editor type) (type: string): the table name where the file will be imported. If left empty, it will take the 'Name' of the CSV File or the 'Root Name' from the XML File.
The Read Only Output variable are the possible output values that the activity will provide:
- Output (type: boolean): outputs True or False if the execution was successful or not.
Execution: the activity will import the lines found in the given file:
- the initial table content:
- the table content after import: