Use this guide to connect your Tulip App to a SQL Database.
Here's an example of how to use Tulip's Connectors feature to connect to a SQL database.
1- Click the "Add New Function" button on the Functions tab.
2- Name the new function (this allows you to pick the specific connector function in Triggers).
Configure the function Inputs and Outputs
In the example above:
Inputs
configuration (text)
Outputs
subconfig_1
subconfig_2
subconfig_3
Query
SELECT subconfig_1, subconfig_2, subconfig_3 FROM webinar database
WHERE configuration = $configuration$
order by id desc
limit 1 ```
A function can have multiple inputs and outputs. You will need at least one input or output in order to send/receive data from a Tulip App.
Click Add to add a new input or output
Give the field a recognizable name
Choose the data type (e.g. Text, Boolean, Integer, etc.)
Add a valid SQL statement into the Query field. Note that the input variable names should be wrapped in $. Example:
$input$
.
Test the function
If the function has inputs, enter valid values
Click "Test" in the top right.
View test results or error messages in the Test Results section
In some cases, you may want to return multiple rows from a SQL table. To do this, check the box next to "Return Multiple Rows". This will return an Array full of Objects, where each object contains values from one row in the SQL table.
Query
SELECT name, num from numbers where num > $number$
(in the example above, number is an input)
Then, when you add your inputs and click "Test", you should see all the expected rows returned under "Test Results".
These can be stored in a Variable as an array full of Objects in the Trigger Editor.
7- Press "Save" when you are finished.
If you need to add new inputs/outputs, you can copy the function and make changes in the new function.
Connectors are how your Tulip apps can connect to other systems. Connectors can make API calls with HTTP Connectors, or pull data directly from SQL databases. Additionally OPC-UA Connectors can be used to retrieve Machine data.
Once pulled, data can be used throughout your applications.
Trigger
Triggers are the mechanism to do things in Tulip Apps. Store data, move users between Steps, Interface with hardware, Etc.
Triggers can be added to widgets, machines, devices, apps, and steps.
Array
Arrays are a Tulip Datatype. Arrays are a list of other variables. Every element in an array must be the same type.
Arrays are very useful when managing multiple values that represent the same information.
ex. The measurements of 10 quality checks can be stored in an Array of Numbers, as opposed to 10 Number variables.
Object
Objects are a Tulip Datatype. Objects represent an arbitrary grouping of attributes. Leveraging objects can simplify the process of working with complex data architectures. Often ConnectorFunctions will return Arrays of Objects
ex. My car object has 5 attributes, Color, Make, Model, # of wheels, # of seats.
Variable
Variables are a location to store app information. Variables have a specific type that must match the contents they can store.
Variables are only accessible within a single application and are cleared when the app is restarted or completed.
Object
Objects are a Tulip Datatype. Objects represent an arbitrary grouping of attributes. Leveraging objects can simplify the process of working with complex data architectures. Often ConnectorFunctions will return Arrays of Objects
ex. My car object has 5 attributes, Color, Make, Model, # of wheels, # of seats.
Trigger
Triggers are the mechanism to do things in Tulip Apps. Store data, move users between Steps, Interface with hardware, Etc.
Triggers can be added to widgets, machines, devices, apps, and steps.
Was this article helpful?
Thank you for your feedback! Our team will get back to you