victoriajae.blogg.se

Inductive automation ignition database query
Inductive automation ignition database query





inductive automation ignition database query

Printing things out as your script is running helps you to see what is actually happening and compare it to what you think should be happening.

inductive automation ignition database query

You can access the console in the designer by selecting it from the Tools menu. Print statments (when run in the designer or client) get output to the console. These simple loops involving print statements are great for debugging and initial script development. Scripts that you implement in your projects will likely be a lot more complex and it may be difficult at first to determine how exactly they should be written in order to accomplish exactly what you need. The above example is very simple, but it shows how you can use for loops to loop through resultsets. #loop through the resultset and print the value in the lastname column Below is a quick example of looping through a PyDataSet There is some basic information about Python Control Flow statements that you should read over as well as the section on dealing with looping through data in PyDataSets. Python, like many other programming languages, provides looping capabilities that make iterating through a resultset quite easy. Much of the time when you run a query in a script it is because you want to examine the resultset in the script and then do some action based on your findings.

inductive automation ignition database query

Merely running a query and then assigning the resulting PyDataSet to a table is really no different than just binding the data property of the table to a SQL Query binding. The reference to your table (myTable) is unique so make sure you select it from the property browser: Assigning the PyDataSet to a table will cause the table to refresh and then display the results from your query. You can assign these results directly to the data property of a table on your window or any other dataset property you may have on a currently open window. SELECT queries return resultsets in the form of PyDataSets. Once you determine the function that best suits the query that you want to run you have to add your script to the script editor section of the actionPerformed event for your button. System.db.createSProcCall, system.db.execSProcCall - These functions are used together to execute any stored procedures you may have in your database.

inductive automation ignition database query

Examples of each of these functions can be found in their linked topic sections. Options such as the ability to return auto generated key for insert queries can be extremely helpful and eliminate the need to hit the database multiple times. Pay close attention to the options provided to you by each of the different functions. The functions listed below are a couple of the functions that you're likely to use the most. Each function serves a different purpose, so the function you use will depend on what type of query you need to run and what sort of results you want to get back. There are some built in scripting functions that Ignition makes available for you to use when running queries against the database. You can find more information about the button component here: Button Any Python script added to this area will be executed when the event fires. In the cases where you wish to write your own custom script for an event, you will make use of the script editor tab. The event handlers window provides you with a list of all the events available for the selected component, along with several script generation wizards for common tasks. To add a script to the actionPerfomed event or view all of the events the button supports, right click on the button you added to the window and select "Event Handlers". There are many different types of events you can add scripting to, but the main event associated with a button press is the actionPerformed event. You can add a button to your window by simply selecting it from the component palette in the designer and then clicking anywhere on your window. Handle the results of a SELECT query (if applicable)







Inductive automation ignition database query