# readBlocking multiple tags and DB insert

**URL:** <https://forum.inductiveautomation.com/t/readblocking-multiple-tags-and-db-insert/71589>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [March 25, 2023, 12:27pm UTC](https://forum.inductiveautomation.com/t/readblocking-multiple-tags-and-db-insert/71589 "2023-03-25T12:27:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matrix\_Engineering](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matrix_engineering/32/19781_2.png) [@Matrix\_Engineering](https://forum.inductiveautomation.com/u/Matrix_Engineering)\
**Post date:** [March 25, 2023, 12:27pm UTC](https://forum.inductiveautomation.com/t/readblocking-multiple-tags-and-db-insert/71589/1 "2023-03-25T12:27:20Z")

</div>

The readBlocking example in the docs shows using a for loop.

If doing a multi-column DB insert of these values, what is the best method?

I can think of a crude one using if, elif statements. I bet someone has a nice one-liner.

I'm only working with a couple of tags for testing now and I will only be adding a few more. I don't mind manually adding extra ? into the Prep query at this stage. I know if it was many tags and subject to a lot of change, Phil etc have provided nice examples of dynamic building of ? based on the length of items.

8.1.25, Gateway Timer Script

---

<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:** [March 25, 2023, 1:07pm UTC](https://forum.inductiveautomation.com/t/readblocking-multiple-tags-and-db-insert/71589/2 "2023-03-25T13:07:20Z")

</div>

This is entirely dependent on your table structure. Show more of what you are trying to achieve.

---

<div class="post-metadata">

**Author:** ![Matrix\_Engineering](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matrix_engineering/32/19781_2.png) [@Matrix\_Engineering](https://forum.inductiveautomation.com/u/Matrix_Engineering)\
**Post date:** [March 25, 2023, 2:12pm UTC](https://forum.inductiveautomation.com/t/readblocking-multiple-tags-and-db-insert/71589/3 "2023-03-25T14:12:04Z")

</div>

Wide table, index AI, multiple columns and a datetime with _CURRENT\_TIMESTAMP()_. (MariaDB).

The multiple columns are all floats. 1-second granularity.

I've done similar in past with 79, looking for guidance on the most efficient 81 methods with readBlocking etc.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [March 27, 2023, 11:09am UTC](https://forum.inductiveautomation.com/t/readblocking-multiple-tags-and-db-insert/71589/4 "2023-03-27T11:09:17Z")

</div>

If you are just using the values, a one-liner would be something like:

```python
tagList = ['[provider]path/to/tag1',
          '[provider]path/to/tag2',
          '[provider]path/to/tag3',
          ...
          '[provider]path/to/tagN'
         ]

values = [qValue.value for qValue in system.tag.readBlocking(tagList)]

```

However, if you also need to iterate over something else, (example: generate the column names from the last portion of the tag path), it becomes more efficient to use a for loop and zip:

```python
tagList = ['[provider]path/to/tag1',
           '[provider]path/to/tag2',
           '[provider]path/to/tag3',
           ...
           '[provider]path/to/tagN'
          ]

colNames = values = []

for tag, qValue in zip(tagList, system.tag.readBlocking(tagList)):
	colNames.append(tag.split('/')[-1])
	values.append(qValue.value)

```

---

<div class="post-metadata">

**Author:** ![Maheswaran\_S](https://avatars.discourse-cdn.com/v4/letter/m/e47c2d/32.png) [@Maheswaran\_S](https://forum.inductiveautomation.com/u/Maheswaran_S)\
**Post date:** [April 5, 2023, 5:49am UTC](https://forum.inductiveautomation.com/t/readblocking-multiple-tags-and-db-insert/71589/5 "2023-04-05T05:49:25Z")

</div>

> [@JordanCClark](#):
>
> `values = [qValue.value for qValue in system.tag.readBlocking(tagList)]`

**you can also do like this** ,

> path = ["[provider]path/to/tag1",  
> "[provider]path/to/tag2"]  
> qualifiedValues = system.tag.readBlocking(path)  
> print qualifiedValues  
> print list(map(lambda x : x.value,qualifiedValues))
