# Ignition database use from modules

**URL:** <https://forum.inductiveautomation.com/t/ignition-database-use-from-modules/105806>\
**Category:** Module Development\
**Tags:** database\
**Created:** [May 2, 2025, 12:13am UTC](https://forum.inductiveautomation.com/t/ignition-database-use-from-modules/105806 "2025-05-02T00:13:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Stone](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/david_stone/32/79749_2.png) [@David\_Stone](https://forum.inductiveautomation.com/u/David_Stone)\
**Post date:** [May 2, 2025, 12:13am UTC](https://forum.inductiveautomation.com/t/ignition-database-use-from-modules/105806/1 "2025-05-02T00:13:10Z")

</div>

Is there any examples of modules around that use their own table in an existing Ignition database?  
Not the SQLite config database, but one of the user defined SQL connections?

---

<div class="post-metadata">

**Author:** ![Benjamin\_Furlani](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/benjamin_furlani/32/66084_2.png) [@Benjamin\_Furlani](https://forum.inductiveautomation.com/u/Benjamin_Furlani)\
**Post date:** [May 2, 2025, 1:08pm UTC](https://forum.inductiveautomation.com/t/ignition-database-use-from-modules/105806/2 "2025-05-02T13:08:51Z")

</div>

In the setup in the gateway hook you can access it via

```Java
    @Override
    public void setup(GatewayContext context) {
        context.getDatasourceManager().getDatasource("MyConnection").getConnection()
   }     

```

I take the context and save it for later to be used for other scopes.

There may be a better way but this is how I figured it out.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [May 2, 2025, 2:37pm UTC](https://forum.inductiveautomation.com/t/ignition-database-use-from-modules/105806/3 "2025-05-02T14:37:18Z")

</div>

This is essentially correct. You absolutely should store the `context` you get in setup in a field in your hook.

Note that there are some potential complications, depending on what you're doing - i.e. you may want to 'fall back' to the project's default database connection. 8.1 vs 8.3 you're going to use the `ScriptContext` class to do that (in gateway scope) but the API of that class is very different in 8.3. You also get a _project_ name over RPC (if you're adding functionality to the client/designer), though again the API to extract that is different in 8.1 vs 8.3.
