Sorry I know this question had probably been asked a billion times but what's the easiest/best way to use a database on arduino?
Looking to scan and search for a barcode, and get the other info related to it (price, name etc). MySQL looks good for that but can't seem to find any clear instruction of how to use it with arduino.
If the database is small and with not to much information, use a struct to organize the information (make a record) and then make an array with this struct with the number of records that you want.
I think it can be the easiest way to do what you want.
The Arduino may not be the idea platform for what you want to do.
Relational databases like SQL or even SQLLite are massive programs by Arduino standards and it doesn't have the memory capacity to run this sort of thing,
Arduino only has a small amount of RAM (generally 2kb ; yes, 2000 bytes) and very little program storage 32k in most boards.
So you'd need to use external storage e.g. SD card is the easiest way.
But this would mean that for each scan, you'd need to open an index file and read it line by line, comparing the bar code with the line the index file. You can then use the line number to reference another file with the data in it.
e.g. have lots of files e.g. product1.txt product2.txt product3.txt
then in index.txt have the bar code numbers
174783469324689
89905389469849
43840290439245
I think this would probably give you the quickest lookup, but would take some managent of filenames
or write it all into one index.csv file
However this may take longer to index if there is a lot of product information. on each line
e.g.
174783469324689 ,$123.45,long description text here long description text here long description text here long description
89905389469849 ,$222.45,long description text here long description text here long description text here long description
43840290439245 ,$133323.45,long description text here long description text here long description text here long description
MYSql and SQlite and such are PC programs. They may also work on a RaspberryPi.
If an Arduino needs data from one of those databases, or if it needs to save data in one of them, the normal way is to have a program running on the PC that interfaces with the database and sends/receives data to/from the Arduino. That way the hard work takes place on the PC and only the smallest amount of essential data is passed to/from the Arduino.
The Arduino could be connected to the barcode scanner and send the code to the PC so that the rest of the work can happen there.
I'm not sure what advantage there would be in sending a product description or price to the Arduino, but it could be done.
In any case I presume you can connect a barcode scanner directly to a PC without needing an Arduino.
The Arduino's strength is its ability to control external hardware which is not easy to do from a PC with a large Operating System.