Inserting Ignition Table element into SQL Table

I have a screen where some data entered. I have 2 text fileds that get filled out by the user (workorder, rollnumber). On the same screen I have a 1 Column 100 Row table where data is automatically input via a set of digital calipers through a Mux box acting as a keyboard wedge. That’s all well and good.

I am able to do a standard script upon click of a button:

queryValue2 = event.source.parent.getComponent('WOtxt').text
queryValue3 = event.source.parent.getComponent('Rolltxt').text

system.db.runPrepUpdate("INSERT INTO AGData (WorkOrder, Roll) VALUES (?,?)", [queryValue2, queryValue3],"Ignition")

But how do I insert the values of the Ignition table into the SQL table. The table should have 100 values in it, I want them to go to SQL fields Bolt1 to Bolt100. Just not sure how to setup the table and then the Query so that all of this can properly be put into the same table.

Any direction appreciated.

This should get you close:

[code]queryString = “Insert INTO AGData (Workorder, Roll” # Beginning of Query String
queryStringAppend = “) VALUES (?,?” # Values portion of Query String, also holds RH parenthesis for column list
table = event.source.parent.getComponent(“IgnitionTableName”) # Location of Igniton Table
data = system.dataset.toPyDataSet( # Convert the Ignition Table to PyDataset
WOtxt = event.source.parent.getComponent(‘WOtxt’).text
Rolltxt = event.source.parent.getComponent(‘Rolltxt’).text

rowVals=[] # List of values used in runPrepUpdate
rowVals.append(WOtxt) # Add Work Order to List
rowVals.append(Rolltxt) # Add Roll to List

i=1 # Index a number to append for ‘Bolt’

for row in data: # Start of loop to grab Bolt Values
rowVals.append(row[“BoltValueColumnFromIgnitionTable”]) # Add Bolt Value to List
queryString += “, Bolt”+str(i) # Add Boltxx to list of column names
queryStringAppend += “,?” # Add a question mark place holder for runPrepUpdate
i+=1 # Add 1 to the index and loop again until we’re out of data

queryString += queryStringAppend + “)” # Put the entire query string together
system.db.runPrepUpdate(querySting, rowVals, “Ignition”) # Run the query


This should automatically generate your column names for the bolts and add as many placeholders as you need. You’ll need to change the Ignition table and its column name to fit. Unless I was really lucky at guessing… :laughing: