# Loop through list or dictionary and insert values into SQL table

**URL:** <https://forum.inductiveautomation.com/t/loop-through-list-or-dictionary-and-insert-values-into-sql-table/22061>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [January 23, 2019, 3:07pm UTC](https://forum.inductiveautomation.com/t/loop-through-list-or-dictionary-and-insert-values-into-sql-table/22061 "2019-01-23T15:07:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mmintenko](https://avatars.discourse-cdn.com/v4/letter/m/9de053/32.png) [@mmintenko](https://forum.inductiveautomation.com/u/mmintenko)\
**Post date:** [January 23, 2019, 3:07pm UTC](https://forum.inductiveautomation.com/t/loop-through-list-or-dictionary-and-insert-values-into-sql-table/22061/1 "2019-01-23T15:07:01Z")

</div>

I’m currently stuck on how to handle the data I’ve received back from an API call. First it’s stored in a list in the following format:

{u’lastActive’: ‘2019-01-23T13:50:03.000Z’, u’displayName’: ‘LV70’, u’type’: ‘vehicle’, u’photoUrl’: ‘[http://localhost/NLTWeb/images/vehicles/Toyota.jpg](http://localhost/NLTWeb/images/vehicles/Toyota.jpg)’, u’name’: ‘LV70’, u’location’: {u’closestKnownLocation’: {u’name’: ‘760-E1-B2’, u’id’: 13}, u’duration’: 2544218, u’lastSeen’: ‘2019-01-23T13:49:51.000Z’, u’location’: {u’level’: {u’name’: ‘Ramp’, u’id’: 1}, u’isInMine’: True, u’position’: {u’coordinates’: [-65.59204146265984, 0.0005485117435425996], u’type’: ‘Point’}}, u’time’: ‘2019-01-23T13:07:33.000Z’}, u’id’: 10000055, u’vehicleType’: {u’name’: ‘Toyota’, u’id’: 5}}

I then converted it to a dictonary, and it’s now in the following format:

10000024 : {u’lastActive’: ‘1970-01-01T00:00:00.000Z’, u’displayName’: ‘U06’, u’type’: ‘vehicle’, u’photoUrl’: None, u’name’: ‘U06’, u’location’: {u’location’: None, u’time’: ‘2019-01-17T17:54:58.971Z’}, u’vehicleType’: {u’name’: ‘Transmixer’, u’id’: 7}}

I want to loop through either the list or the dictionary, map the values that end with a “:” to a field in a table, and insert the value after the “:”

My Googling is not getting me far, and Python is a whole new world to me. Any help is greatly appreciated.

Thanks,  
Mikael
