# Using system.db.refresh() to update connection to a global script

**URL:** <https://forum.inductiveautomation.com/t/using-system-db-refresh-to-update-connection-to-a-global-script/80026>\
**Category:** Ignition\
**Created:** [October 4, 2023, 4:33pm UTC](https://forum.inductiveautomation.com/t/using-system-db-refresh-to-update-connection-to-a-global-script/80026 "2023-10-04T16:33:36Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bushmatic](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bushmatic/32/87014_2.png) [@Bushmatic](https://forum.inductiveautomation.com/u/Bushmatic)\
**Post date:** [October 4, 2023, 4:33pm UTC](https://forum.inductiveautomation.com/t/using-system-db-refresh-to-update-connection-to-a-global-script/80026/1 "2023-10-04T16:33:36Z")

</div>

I am trying to figure out how to use system.db.refresh() in a project in order to refresh the binding to our "LabelPrintRack" shared (global) script below. There are changes made to this script that I need to utilize in this project but I can't figure out how to refresh this connection. This is on a simple button-push event in the current project that feeds some parameters into the mentioned LabelPrintRack script.

Does anyone know if this is the right method to refresh this script connection? If so how exactly should the arguments look for this? Thanks for the help and sorry if this is a dumb question.

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/7/672d029c1dd17bac3f53bed5d9710794b326403d.png)

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [October 4, 2023, 4:42pm UTC](https://forum.inductiveautomation.com/t/using-system-db-refresh-to-update-connection-to-a-global-script/80026/2 "2023-10-04T16:42:14Z")

</div>

[https://docs.inductiveautomation.com/display/DOC80/system.db.refresh](https://docs.inductiveautomation.com/display/DOC80/system.db.refresh)

System.db.refresh is for refreshing a SQL Binding on a JComponent, a vision component.

What exactly is the issue you are running into you need to resolve?

---

<div class="post-metadata">

**Author:** ![Bushmatic](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bushmatic/32/87014_2.png) [@Bushmatic](https://forum.inductiveautomation.com/u/Bushmatic)\
**Post date:** [October 4, 2023, 4:52pm UTC](https://forum.inductiveautomation.com/t/using-system-db-refresh-to-update-connection-to-a-global-script/80026/3 "2023-10-04T16:52:36Z")

</div>

I have a project that is used for label printing that calls the LabelPrintRack function via inheritance. Let's say this project is called "PrintProject" and the global one is just called "Global." Global has the LabelPrintRack script that I need to call and use inside PrintProject.

But after updating the LabelPrintRack function in Global and saving that project, I have opened the other project PrintProject to find it is still "looking at" at the previous version of Global. So the updates I have made are not seen and thus I am running into a roadblock...

---

<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:** [October 4, 2023, 5:01pm UTC](https://forum.inductiveautomation.com/t/using-system-db-refresh-to-update-connection-to-a-global-script/80026/4 "2023-10-04T17:01:37Z")

</div>

In your code in `LabelPrintRack`, are you using `import` to pull in the functions from `Global`? If so, don't. Just use the fully-qualified name of functions in `Global` anywhere else you need them. (You should never import a project library script. Only use import with java classes and jython site-packages.)

---

<div class="post-metadata">

**Author:** ![Bushmatic](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bushmatic/32/87014_2.png) [@Bushmatic](https://forum.inductiveautomation.com/u/Bushmatic)\
**Post date:** [October 4, 2023, 6:07pm UTC](https://forum.inductiveautomation.com/t/using-system-db-refresh-to-update-connection-to-a-global-script/80026/5 "2023-10-04T18:07:31Z")

</div>

Nope, doesn't look like that is how it is set up. I am working with a legacy Ignition MES made by someone who is no longer around, so I'm always open to ways to do things better.

Can I ask why that is bad practice? Just so I can understand things a bit better

---

<div class="post-metadata">

**Author:** ![Felipe\_CRM](https://avatars.discourse-cdn.com/v4/letter/f/dfb087/32.png) [@Felipe\_CRM](https://forum.inductiveautomation.com/u/Felipe_CRM)\
**Post date:** [October 4, 2023, 6:11pm UTC](https://forum.inductiveautomation.com/t/using-system-db-refresh-to-update-connection-to-a-global-script/80026/6 "2023-10-04T18:11:58Z")

</div>

When you import a project script, it'll bring a copy of the Python code into the local script _as it was at the time of import_, which can cause all kinds of fun:

> [@Some Project Resources not publishing](https://forum.inductiveautomation.com/t/some-project-resources-not-publishing/16888/3):
>
> This may be a side-effect of the fact that Ignition doesn’t/can’t track the usage and retention of python code objects throughout the gateway. This means that when your script modules have interlocking dependencies, updating one script won’t impact the code objects that other scripts have imported. You may need to make a trivial change in all of your scripts and save them all together to get it to “take”. You may also need to disable then re-enable the entire project. Consider renaming the o…

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [October 4, 2023, 6:15pm UTC](https://forum.inductiveautomation.com/t/using-system-db-refresh-to-update-connection-to-a-global-script/80026/7 "2023-10-04T18:15:02Z")

</div>

I tend to use this to avoid very long and ugly looking full path, particularly if it's a function I'm using a lot:

```python
func = some_module/and_some_folder/some_script.func_from_far_away

```

bad idea ?

---

<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:** [October 4, 2023, 8:34pm UTC](https://forum.inductiveautomation.com/t/using-system-db-refresh-to-update-connection-to-a-global-script/80026/8 "2023-10-04T20:34:54Z")

</div>

> [@pascal.fragnoud](#):
>
> bad idea ?

At the outermost level of the script? Yes, it's a bad idea. It is effectively an import because it persists for the life of the library script.

Nested in a function that will execute and go out of scope relatively quickly? (This assignment itself, not just usage.) Not a problem.
