question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inserting into and retrieving from binary string column

See original GitHub issue

Hello,

I have a table MyKeys with a column that is a binary string of length 16 bytes: CREATE TABLE MyKeys (id INT AUTO_INCREMENT PRIMARY KEY, myKey BINARY(16)) Now I create an ArrayBuffer of size 16 bytes: var myBuffer = new ArrayBuffer(16); Now I want to insert it into the table: con.query('INSERT INTO MyKeys (myKey) VALUES (?)', [myBuffer],function (err, data) {}); However that is causing an error: ER_WRONG_VALUE_COUNT_ON_ROW: Column count doesn’t match value count at row 1 sql: “INSERT INTO MyKeys (myKey) VALUES ()” So it looks like myBuffer is not being sent to MySQL at all.

Any suggestions would be much appreciated. Thanks!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
sameerjalnapurkarcommented, Apr 7, 2020

Seems to be working now. Thanks a million, @sidorares & @dougwilson

1reaction
dougwilsoncommented, Apr 7, 2020

An ArrayBuffer cannot be read directly, as you need to overlay some kind of view over it to read. The Node.js Buffer is a view into an ArrayBuffer. You can create a Buffer view of an ArrayBuffer using Buffer.from(myArrayBuffer)

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I insert arbitrary binary data into a VARCHAR column?
Save this answer. Show activity on this post. The short answer is that it shouldn't be possible to insert values with invalid UTF8...
Read more >
11.3.3 The BINARY and VARBINARY Types
The BINARY and VARBINARY types are similar to CHAR and VARCHAR , except that they store binary strings rather than nonbinary strings.
Read more >
Inserting binary string at an offset to exsting data in a Text type ...
Is it possible to insert binary data in an existing text column, into existing binary data (text type) stored in there, to an...
Read more >
How do I identify the column(s) responsible for "String or ...
String or binary data would be truncated in table 'tempdb.dbo.x', column 'a'. Truncated value: 'f'. The statement has been terminated. Until you can...
Read more >
String & Binary Data Types - Snowflake Documentation
Data Types for Binary Strings. BINARY. VARBINARY. Internal Representation. Binary Examples in Table Columns. String Constants.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found