# AttributeError: 'com.inductiveautomation.ignition.common.script.Imm' object has no attribute 'db'

**URL:** <https://forum.inductiveautomation.com/t/attributeerror-com-inductiveautomation-ignition-common-script-imm-object-has-no-attribute-db/85934>\
**Category:** Ignition\
**Tags:** ignition79, vision\
**Created:** [February 19, 2024, 1:18pm UTC](https://forum.inductiveautomation.com/t/attributeerror-com-inductiveautomation-ignition-common-script-imm-object-has-no-attribute-db/85934 "2024-02-19T13:18:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zxcslo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zxcslo/32/61610_2.png) [@zxcslo](https://forum.inductiveautomation.com/u/zxcslo)\
**Post date:** [February 19, 2024, 1:18pm UTC](https://forum.inductiveautomation.com/t/attributeerror-com-inductiveautomation-ignition-common-script-imm-object-has-no-attribute-db/85934/1 "2024-02-19T13:18:08Z")

</div>

Can somebody shed some light on the error, that one of our customers got on Ignition 7.9.21...?

 ![Screenshot_145](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/7/f78cfcb64dee52be0b1a339b1f5baf2242c295b1.png)

validateInputImeRecepture is a custom method on the root container to verify, if the recipe name is valid:

 ![Screenshot_146](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/9/19ac6e6f0ec527242e41989ecd66489660e7eb4e.png)

```auto
def validateInputImeRecepture(self):
	invalidMessageCompReceptura = self.getComponent("InvalidMessageReceptura")
	
	novareceptura = self.getComponent("txtImeRecepture").text
	if novareceptura != None:
		exists = system.db.runPrepQuery("SELECT COUNT(*) FROM recipes WHERE ime_recepture = ?", [novareceptura])[0][0]
		if len(novareceptura)==0 or exists:
			invalidMessageCompReceptura.text = u"Že obstaja!"
			invalidMessageCompReceptura.visible = True
			self.IsValidImeRecepture = False
			return
	
	invalidMessageCompReceptura.visible = False
	
	self.IsValidImeRecepture = True

```

line 12 is this line:

```auto
exists = system.db.runPrepQuery("SELECT COUNT(*) FROM recipes WHERE ime_recepture = ?", [novareceptura])[0][0]

```

It's interesting that this happens every now and then and not always...  
Most of the time the call to this custom method works like it should.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 19, 2024, 1:21pm UTC](https://forum.inductiveautomation.com/t/attributeerror-com-inductiveautomation-ignition-common-script-imm-object-has-no-attribute-db/85934/2 "2024-02-19T13:21:42Z")

</div>

Bug (rare race condition) in script environment setup for custom functions, IIRC. Not fixed until sometime in v8.1.

Two ways forward:

- Upgrade 🙄

- Move code to a project library script and make custom function a one-liner that delegates to the library. (I would do this latter anyways, everywhere, and for all events, too.)

---

<div class="post-metadata">

**Author:** ![zxcslo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zxcslo/32/61610_2.png) [@zxcslo](https://forum.inductiveautomation.com/u/zxcslo)\
**Post date:** [February 19, 2024, 1:27pm UTC](https://forum.inductiveautomation.com/t/attributeerror-com-inductiveautomation-ignition-common-script-imm-object-has-no-attribute-db/85934/3 "2024-02-19T13:27:55Z")

</div>

OK, the upgrade is out of the question, so **move the code to the project library** it is...  
Thanks, @pturmel 👍 🍻
