# Is a possible to insert device details in SQL through ignition?

**URL:** <https://forum.inductiveautomation.com/t/is-a-possible-to-insert-device-details-in-sql-through-ignition/83252>\
**Category:** Ignition\
**Tags:** ignition81, vision\
**Created:** [December 18, 2023, 12:31pm UTC](https://forum.inductiveautomation.com/t/is-a-possible-to-insert-device-details-in-sql-through-ignition/83252 "2023-12-18T12:31:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Govind\_Suthar1](https://avatars.discourse-cdn.com/v4/letter/g/a87d85/32.png) [@Govind\_Suthar1](https://forum.inductiveautomation.com/u/Govind_Suthar1)\
**Post date:** [December 18, 2023, 12:31pm UTC](https://forum.inductiveautomation.com/t/is-a-possible-to-insert-device-details-in-sql-through-ignition/83252/1 "2023-12-18T12:31:18Z")

</div>

Hello everyone,

I have a question about the SQL query in ignition. Is it possible to insert new device details in SQL through a query using ignition UI?

Example,Suppose in the ignition four sensors are connected. (Like a temperature, pressure) Now, the other four sensors added in the field and I want to not add sensor details manually in MySQL for data logging. \*  
\*\*\* So, I add multiple numeric text fields in the ignition and add these details in the numeric text field (Such as sensor name, sensor mac\_id, gateway\_id,)and then add a button for the insert of the query. when I press the button that time insert query will be run on raw will be added to the database.\*\*

---

<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:** [December 18, 2023, 1:10pm UTC](https://forum.inductiveautomation.com/t/is-a-possible-to-insert-device-details-in-sql-through-ignition/83252/2 "2023-12-18T13:10:42Z")

</div>

Your question is unclear.

1. Have you created OPC tags for these four new sensors?
2. Are you using Ignition's Historian or are you logging these in your own custom database?

> So, I add multiple numeric text fields in the ignition ...

Do you mean, "In the Vision window I have added multiple Numeric Text Field components ..."

> ... and add these details in the numeric text field (Such as sensor name, sensor mac\_id, gateway\_id,) and then add a button for the insert of the query.

OK. So you have created a form with Numeric Text Field components, but you can't enter text names, MAC address or gateway\_id in a numeric field.

> When I press the button that time insert query will be run on raw will be added to the database.

That should be OK.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [December 18, 2023, 5:30pm UTC](https://forum.inductiveautomation.com/t/is-a-possible-to-insert-device-details-in-sql-through-ignition/83252/3 "2023-12-18T17:30:05Z")

</div>

> [@Govind\_Suthar1](#):
>
> Is it possible to insert new device details in SQL through a query using ignition UI?

It's certainly possible to execute a sql statement in ignition, whether that's a SELECT, INSERT, DELETE, etc. But is this what you actually mean, or are you actually asking if you can add a new Device connection (eg to a new PLC) to the gateway via script, or add new tags (eg UDT instances) for the new sensors into the tag tree via script?

---

<div class="post-metadata">

**Author:** ![Govind\_Suthar1](https://avatars.discourse-cdn.com/v4/letter/g/a87d85/32.png) [@Govind\_Suthar1](https://forum.inductiveautomation.com/u/Govind_Suthar1)\
**Post date:** [December 19, 2023, 5:43am UTC](https://forum.inductiveautomation.com/t/is-a-possible-to-insert-device-details-in-sql-through-ignition/83252/4 "2023-12-19T05:43:54Z")

</div>

> [@nminchin](#):
>
> whether that's a SELECT, INSERT, DELETE, etc. But is this what you actually mean

I need to add new tag via script in the database.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [December 19, 2023, 7:44am UTC](https://forum.inductiveautomation.com/t/is-a-possible-to-insert-device-details-in-sql-through-ignition/83252/6 "2023-12-19T07:44:17Z")

</div>

You can use system.tag.configure to create new tags via script. It just need a base folder to create them in and the tag's to create as a list of tag json objects. Copy the json of other similar tags for a reference. For udt instances I would recommend removing all tags keys from the json unless you're adding property overrides, as they're useless and just clutter the json

---

<div class="post-metadata">

**Author:** ![Govind\_Suthar1](https://avatars.discourse-cdn.com/v4/letter/g/a87d85/32.png) [@Govind\_Suthar1](https://forum.inductiveautomation.com/u/Govind_Suthar1)\
**Post date:** [December 20, 2023, 4:45am UTC](https://forum.inductiveautomation.com/t/is-a-possible-to-insert-device-details-in-sql-through-ignition/83252/9 "2023-12-20T04:45:42Z")

</div>

can you brief it with example for inserting raw in the database?

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [December 20, 2023, 4:57am UTC](https://forum.inductiveautomation.com/t/is-a-possible-to-insert-device-details-in-sql-through-ignition/83252/10 "2023-12-20T04:57:59Z")

</div>

```auto
machineName = "Machine01"
tags = {
  "name": machineName,
  "tagType": "Folder",
  "tags": [
    {
      "name": "Tools",
      "tagType": "Folder",
      "tags": [] 
    },
    {
      "name": "Alarm Summary",
      "typeId": "Alarm Summary",
      "tagType": "UdtInstance",
      "tags": [] # there were originally lots of tags in this list which I removed as they're not required to import the UDT instance
    },
    {
      "name": "Common",
      "typeId": "SPL/Roll Machine",
      "parameters": {
        "Description": {
          "dataType": "String",
          "value": machineType
        },
        "PLCName": {
          "dataType": "String",
          "value": machineName
        }
      },
      "tagType": "UdtInstance",
      "tags": [] # there were originally lots of tags in this list which I removed as they're not required to import the UDT instance
    }
  ]
}
system.tag.configure('Path/To/Machines/Folder', tags, 'm')

```

Also, you don't need to delete a post, you can just edit it to make changes to it
