# Vision Checkbox - MySQL

**URL:** <https://forum.inductiveautomation.com/t/vision-checkbox-mysql/108523>\
**Category:** Ignition\
**Tags:** ignition81, vision, scripting\
**Created:** [July 15, 2025, 8:07pm UTC](https://forum.inductiveautomation.com/t/vision-checkbox-mysql/108523 "2025-07-15T20:07:25Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![warren](https://avatars.discourse-cdn.com/v4/letter/w/97f17d/32.png) [@warren](https://forum.inductiveautomation.com/u/warren)\
**Post date:** [July 15, 2025, 8:07pm UTC](https://forum.inductiveautomation.com/t/vision-checkbox-mysql/108523/1 "2025-07-15T20:07:25Z")

</div>

Does anyone know the correct MySQL data format to allow me to use the Named Query result as a controller for the Vision checkbox? I tried BIT(1), TINYINT but no luck?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/0/f08d9c025da5b9026b9f01b0d40499e3bb061388.png)

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/8/28f11ce33d8107f5055ec5b7915fc7ec3af08f9e.png)

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [July 15, 2025, 8:10pm UTC](https://forum.inductiveautomation.com/t/vision-checkbox-mysql/108523/2 "2025-07-15T20:10:33Z")

</div>

I don't, but I can see that the Default/Expression is '1' which is a string.  
SQL syntax, surely, would be `TRUE` or `1`?  
Do I see more apostrophes on the next columns default as well?

---

<div class="post-metadata">

**Author:** ![warren](https://avatars.discourse-cdn.com/v4/letter/w/97f17d/32.png) [@warren](https://forum.inductiveautomation.com/u/warren)\
**Post date:** [July 15, 2025, 8:22pm UTC](https://forum.inductiveautomation.com/t/vision-checkbox-mysql/108523/3 "2025-07-15T20:22:08Z")

</div>

I had tried 1, TRUE:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/e/ce87bf653bc0bb37edcaff83758e77604731d92b.png)

---

<div class="post-metadata">

**Author:** ![josborn](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@josborn](https://forum.inductiveautomation.com/u/josborn)\
**Post date:** [July 15, 2025, 8:28pm UTC](https://forum.inductiveautomation.com/t/vision-checkbox-mysql/108523/4 "2025-07-15T20:28:28Z")

</div>

I use TINYINT(1) which i believe is what BIT(1) is an alias for.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [July 15, 2025, 8:39pm UTC](https://forum.inductiveautomation.com/t/vision-checkbox-mysql/108523/5 "2025-07-15T20:39:21Z")

</div>

`DEFAULT 'TRUE'` is also a string.  
Try `DEFAULT TRUE`.  
`'TRUE'` is a string. `TRUE` is a boolean.

---

<div class="post-metadata">

**Author:** ![warren](https://avatars.discourse-cdn.com/v4/letter/w/97f17d/32.png) [@warren](https://forum.inductiveautomation.com/u/warren)\
**Post date:** [July 15, 2025, 8:55pm UTC](https://forum.inductiveautomation.com/t/vision-checkbox-mysql/108523/6 "2025-07-15T20:55:01Z")

</div>

I got it to work by doing the TINYINT and setting default to = 1

I noticed once I write this change to the database, it will go back and reset that 1 to equal '1'. Seems like it doesn't mind in this case.

I got the checkbox to be happy querying this type. But, when reading back the checkbox value, it will convert 1 = 'TRUE', 0 = 'FALSE', which is a problem when reading the checkbox value and updating the database.

I figured this script would do it:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/f/2f1a222d29b6db12a6f92d15aa670f129e533a04.png)

But, it considers 'etchingenable' as undefined if I put that into the parameters string. What would be the correct way to format that change?

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [July 15, 2025, 9:08pm UTC](https://forum.inductiveautomation.com/t/vision-checkbox-mysql/108523/7 "2025-07-15T21:08:49Z")

</div>

Please see [Wiki - how to post code on this forum](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831) so that someone can copy it and edit.

Is `etchingenable` a string? You're assigning a string variable to it.

---

<div class="post-metadata">

**Author:** ![warren](https://avatars.discourse-cdn.com/v4/letter/w/97f17d/32.png) [@warren](https://forum.inductiveautomation.com/u/warren)\
**Post date:** [July 15, 2025, 9:11pm UTC](https://forum.inductiveautomation.com/t/vision-checkbox-mysql/108523/8 "2025-07-15T21:11:38Z")

</div>

Here's the script:

```python
recipe_selected = system.tag.readBlocking('[default]Internal/ActiveHeatRecipe')[0].value
readetching = event.source.parent.getComponent('Etching Parameters').getComponent('Enable Field').selected
if readetching == 'False':
	etchingenable = '0'
if readetching == 'True':
	etchingenable = '1'
etchingpressure = event.source.parent.getComponent('Etching Parameters').getComponent('Starting Pressure Field').text
etchingvoltage = event.source.parent.getComponent('Etching Parameters').getComponent('Discharge Voltage Field').text
etchingmins = event.source.parent.getComponent('Etching Parameters').getComponent('Etching Mins Field').text
etchingsecs = event.source.parent.getComponent('Etching Parameters').getComponent('Etching Secs Field').text
preprocesspeed = event.source.parent.getComponent('Rotation Parameters').getComponent('Preprocess Speed Field').text
processspeed = event.source.parent.getComponent('Rotation Parameters').getComponent('Process Speed Field').text
heaterpressure = event.source.parent.getComponent('Heat Parameters').getComponent('Pressure Field').text
ventenable = event.source.parent.getComponent('Vent Parameters').getComponent('Auto Vent Field').selected
venthours = event.source.parent.getComponent('Vent Parameters').getComponent('Delay Hours Field').text
ventmins = event.source.parent.getComponent('Vent Parameters').getComponent('Delay Mins Field').text
depositionpressure = event.source.parent.getComponent('Process Parameters').getComponent('Starting Pressure Field').text
parameters = {'recipe_selected' : recipe_selected, 'etchingEnable' : txetching, 'etchingPressure' : etchingpressure, 'etchingVoltage' : etchingvoltage, 'etchingMins' : etchingmins, 'etchingSecs' : etchingsecs, 'processSpeed' : processspeed, 'heaterPressure' : heaterpressure, 'ventEnable' : ventenable, 'ventHours' : venthours, 'depositionPressure' : depositionpressure}
system.db.runNamedQuery('PROCESS NQ/PARAMETERS/SAVE PARAMETERS', parameters)

```

---

<div class="post-metadata">

**Author:** ![josborn](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@josborn](https://forum.inductiveautomation.com/u/josborn)\
**Post date:** [July 15, 2025, 9:12pm UTC](https://forum.inductiveautomation.com/t/vision-checkbox-mysql/108523/9 "2025-07-15T21:12:05Z")

</div>

There shouldn't be any issues with writing a Boolean back to the database. You cannot write a string back, why type is your parameter that is writing back to the database?

Also i dont see where you have defined "txetching" `'etchingEnable' : txetching`

---

<div class="post-metadata">

**Author:** ![Leor\_Fishman](https://avatars.discourse-cdn.com/v4/letter/l/e19adc/32.png) [@Leor\_Fishman](https://forum.inductiveautomation.com/u/Leor_Fishman)\
**Post date:** [July 16, 2025, 2:12am UTC](https://forum.inductiveautomation.com/t/vision-checkbox-mysql/108523/10 "2025-07-16T02:12:02Z")

</div>

txetching should read etchingenable, almost certainly

---

<div class="post-metadata">

**Author:** ![warren](https://avatars.discourse-cdn.com/v4/letter/w/97f17d/32.png) [@warren](https://forum.inductiveautomation.com/u/warren)\
**Post date:** [July 16, 2025, 2:51pm UTC](https://forum.inductiveautomation.com/t/vision-checkbox-mysql/108523/11 "2025-07-16T14:51:26Z")

</div>

Sorry, I deleted txetching = etchingenable line because it was throwing an error. Issue is etchingenabled goes undefined with these if statements

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [July 16, 2025, 3:01pm UTC](https://forum.inductiveautomation.com/t/vision-checkbox-mysql/108523/12 "2025-07-16T15:01:39Z")

</div>

You didn't address my earlier comments about is `etchingenable` a string?

```python
if readetching == 'False': # <--- You're checking for a string, not a bool.
	etchingenable = '0' # <--- You're writing a string.
if readetching == 'True': # <--- You're checking for a string, not a bool.
	etchingenable = '1' # <--- You're writing a string.

```

> [@warren](#):
>
> Issue is etchingenable **d** goes undefined with these if statements

Take care with your writing. The variable name is `etchingenable`.

---

<div class="post-metadata">

**Author:** ![warren](https://avatars.discourse-cdn.com/v4/letter/w/97f17d/32.png) [@warren](https://forum.inductiveautomation.com/u/warren)\
**Post date:** [July 16, 2025, 3:27pm UTC](https://forum.inductiveautomation.com/t/vision-checkbox-mysql/108523/13 "2025-07-16T15:27:46Z")

</div>

Yes etchingenable was a string in the NQ, which was throwing the whole thing off. I am able to ignore this whole set of if statements and just use readBlocking on the checkbox. Everything is happy with that. Thanks you!
