7
7
700ghz2016-04-19 18:10:04
Database
700ghz, 2016-04-19 18:10:04

How to store array of bytes in database?

Hi!
On the client (js) there is an array of bytes. For example: [104,236,116,246] (4 bytes here).
You need to transfer this array to the server and store it in the database.
Converting an array to json, passing it and storing it as a string is not rational (now one 1 byte takes 3 bytes).
You can convert each byte to a UTF-8 character, for example. But I don't think it's reliable.
How to implement it correctly?
Thank you.
PS DBMS - sqlite3

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey, 2016-04-19
@700ghz

1) BLOB
2) pack to int32

S
Stanislav Makarov, 2016-04-19
@Nipheris

Have you tried opening the docks?
sqlite.org/datatype3.html

blob. The value is a blob of data stored exactly as it was input.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question