# Blobs in SQLite

**URL:** <https://forums.losant.com/t/blobs-in-sqlite/3723>\
**Category:** Help\
**Tags:** edge\
**Created:** [April 9, 2021, 6:39pm UTC](https://forums.losant.com/t/blobs-in-sqlite/3723 "2021-04-09T18:39:49Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lars\_Andersson](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@Lars\_Andersson](https://forums.losant.com/u/Lars_Andersson)\
**Post date:** [April 9, 2021, 6:39pm UTC](https://forums.losant.com/t/blobs-in-sqlite/3723/1 "2021-04-09T18:39:49Z")

</div>

I have a SQLite .db file on an edge device.  
I can query text, integers and floats, but not blobs.  
Is there a special procedure for that?

---

<div class="post-metadata">

**Author:** ![Heath](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/heath/32/3036_2.png) [@Heath](https://forums.losant.com/u/Heath)\
**Post date:** [April 9, 2021, 7:44pm UTC](https://forums.losant.com/t/blobs-in-sqlite/3723/3 "2021-04-09T19:44:00Z")

</div>

@Lars_Andersson,

Are you seeing any errors when you query blobs or is the query empty?

Would you be able to share with me your SQLite node configuration?

Thank you,  
Heath

---

<div class="post-metadata">

**Author:** ![Lars\_Andersson](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@Lars\_Andersson](https://forums.losant.com/u/Lars_Andersson)\
**Post date:** [April 9, 2021, 7:52pm UTC](https://forums.losant.com/t/blobs-in-sqlite/3723/7 "2021-04-09T19:52:10Z")

</div>

I see no errors

 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/d/dc27ee99d71c66074e9db60a0b14b28eced25859.png)

---

<div class="post-metadata">

**Author:** ![Lars\_Andersson](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@Lars\_Andersson](https://forums.losant.com/u/Lars_Andersson)\
**Post date:** [April 9, 2021, 7:54pm UTC](https://forums.losant.com/t/blobs-in-sqlite/3723/9 "2021-04-09T19:54:19Z")

</div>

The below fields selected are not blobs, then it returns the data correct.  
As soon as I add a blob field, nothing happens, no errors either. Nothing returned to the debug console.

---

<div class="post-metadata">

**Author:** ![Heath](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/heath/32/3036_2.png) [@Heath](https://forums.losant.com/u/Heath)\
**Post date:** [April 9, 2021, 7:55pm UTC](https://forums.losant.com/t/blobs-in-sqlite/3723/10 "2021-04-09T19:55:55Z")

</div>

@Lars_Andersson,

Do you have logging enabled? Is there any information in the Edge Agent log?

Thank you,  
Heath

---

<div class="post-metadata">

**Author:** ![Heath](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/heath/32/3036_2.png) [@Heath](https://forums.losant.com/u/Heath)\
**Post date:** [April 9, 2021, 8:55pm UTC](https://forums.losant.com/t/blobs-in-sqlite/3723/11 "2021-04-09T20:55:21Z")

</div>

@Lars_Andersson,

Thanks for sending me some private information in a DM.

We did some digging and it looks like the resulting query returns 5 blobs that are ~180kb each. This would indicate that the payload you are generating is too large to be displayed in the debug panel.

This means that the workflow was likely executing correctly but the data was not being displayed in the debug panel.

Thank you,  
Heath

---

<div class="post-metadata">

**Author:** ![Lars\_Andersson](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@Lars\_Andersson](https://forums.losant.com/u/Lars_Andersson)\
**Post date:** [April 9, 2021, 10:05pm UTC](https://forums.losant.com/t/blobs-in-sqlite/3723/15 "2021-04-09T22:05:24Z")

</div>

So when the returned data is too large, the debug console shows nothing?

---

<div class="post-metadata">

**Author:** ![Brandon\_Cannaday](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/brandon_cannaday/32/14_2.png) [@Brandon\_Cannaday](https://forums.losant.com/u/Brandon_Cannaday)\
**Post date:** [April 10, 2021, 3:45pm UTC](https://forums.losant.com/t/blobs-in-sqlite/3723/17 "2021-04-10T15:45:24Z")

</div>

Debug messages adhere to the same 256kb size limit for all MQTT messages. So in this case, the message was sent, but rejected by the broker.

There’s some improvements we can make here. Ideally some message should still show up indicating the debug node was executed. I submitted a ticket to investigate options.

---

<div class="post-metadata">

**Author:** ![Lars\_Andersson](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@Lars\_Andersson](https://forums.losant.com/u/Lars_Andersson)\
**Post date:** [April 12, 2021, 8:20pm UTC](https://forums.losant.com/t/blobs-in-sqlite/3723/19 "2021-04-12T20:20:00Z")

</div>

My intention was to report this blob as a device state to one of the attributes that are defined as a blob of content type image/png.  
Will that be possible, even though I can’t see anything in the debug console, or will this be rejected all together?

---

<div class="post-metadata">

**Author:** ![Brandon\_Cannaday](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/brandon_cannaday/32/14_2.png) [@Brandon\_Cannaday](https://forums.losant.com/u/Brandon_Cannaday)\
**Post date:** [April 12, 2021, 8:46pm UTC](https://forums.losant.com/t/blobs-in-sqlite/3723/21 "2021-04-12T20:46:21Z")

</div>

The maximum size of a blob attribute is 256kb. As long as what you’re reporting is less than that, when Base64 encoded, it can be reported.

The Debug Panel likely inflates the size quite a bit because of the JSON representation. You can Base64 encode the file locally and check the file size.

---

<div class="post-metadata">

**Author:** ![Lars\_Andersson](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@Lars\_Andersson](https://forums.losant.com/u/Lars_Andersson)\
**Post date:** [April 12, 2021, 8:57pm UTC](https://forums.losant.com/t/blobs-in-sqlite/3723/22 "2021-04-12T20:57:13Z")

</div>

I realized I was selecting 5 records containing a blob each, so when I limit the result to 1, I can see the data returned in the debug window, but it’s as an array, type “buffer” with 188342 items in it.  
Do I need to encode this in the sql statement before it’s executed or can I encode the payload data ?  
A little lost here, but it at least returning data.

---

<div class="post-metadata">

**Author:** ![Brandon\_Cannaday](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/brandon_cannaday/32/14_2.png) [@Brandon\_Cannaday](https://forums.losant.com/u/Brandon_Cannaday)\
**Post date:** [April 12, 2021, 9:13pm UTC](https://forums.losant.com/t/blobs-in-sqlite/3723/23 "2021-04-12T21:13:52Z")

</div>

You will likely need to convert the array of bytes into a Base64 string using a Function Node. Something like:

```auto
let buf = Buffer.from(payload.working.queryResult.data);
payload.working.encodedImage = buf.toString('base64');

```

I did not explicitly test this, but it should point you in the right direction.
