# Raspberry Pi barcode into mysql database

**URL:** https://discourse.nodered.org/t/raspberry-pi-barcode-into-mysql-database/37087
**Category:** General
**Created:** [6 December 2020 15:58 UTC](https://discourse.nodered.org/t/raspberry-pi-barcode-into-mysql-database/37087 "2020-12-06T15:58:29Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![aqueousdan](https://avatars.discourse-cdn.com/v4/letter/a/2acd7d/32.png) [@aqueousdan](https://discourse.nodered.org/u/aqueousdan)
#### Post date: [6 December 2020 15:58 UTC](https://discourse.nodered.org/t/raspberry-pi-barcode-into-mysql-database/37087/1 "2020-12-06T15:58:29Z")

</div>

Hi all,

Does anyone have any idea how to integrate a barcode scanner output into a database using Nodered?

I have managed to get my scanner to output to the raspberry pi as text but i dont know how to get this to enter into a field in a database.

I have managed to get it so that using my code i can enter a payload in when i press the trigger.

I just need to combine these so that when i scan a barcode, it sends this into the database.

my code is:

```auto
[{"id":"4a69b8be.91c7f8","type":"function","z":"d2d1488a.5a49f8","name":"Query","func":"/*\nIn this function I enter my Raspberry Pi's CPU\ntemperature using the command \"vcgencmd measure_temp\".\nI then store this temperature in the variable temp,\ndo the necessary formatting and then send a database\nquery to enter the temperature in a database named\nNode-RED-test and the field named Field in the table\nnamed test, every two seconds.\n*/\nvar test = msg.payload\nmsg.topic = \"INSERT INTO testtable(testfield) VALUES('\"+test+\"')\";\n\nreturn msg;\n\n","outputs":1,"noerr":0,"x":430,"y":220,"wires":[["3dc5f360.9a44ec","e39c9d28.7e3d8","936b7279.b1f2"]]}]

```

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [6 December 2020 20:07 UTC](https://discourse.nodered.org/t/raspberry-pi-barcode-into-mysql-database/37087/2 "2020-12-06T20:07:00Z")

</div>

Most barcode scanners seem to work as HID devices (the same as a keyboard). So you need something that is able to listen for keyboard input and then translate it into something that Node-RED can understand.

Come to think of it, I vaguely remember there being a keyboard node?

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [4 February 2021 20:07 UTC](https://discourse.nodered.org/t/raspberry-pi-barcode-into-mysql-database/37087/3 "2021-02-04T20:07:03Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
