stefycraft wrote: ↑Thu Feb 06, 2020 2:03 pm
Hi, everyone
I'm working for a project to measure some data with sensor, like temperature, pressure and altitudine, save them to a database MySQL and then send them to a web server (Apache, php). I done all the steps and is all working. I have a few doubts and questions:
1. Where is situated the database? Is it in the Raspberry?
2. Is there a way to consult the data table?
3. How much memory has the database?
4. When the database reaches the max memory, what does it do to the new data?
I'm working with a Raspberry 3B and with a sensor BMP180. I measure tha data every 5 minutes
1. I think you need to learn a bit more about relational databases, of which MySQL is one example. It doesn't keep the data in memory. Rather, it stores it in the file system. When the filesystem runs out of space, the OS will complain, so pick your storage media (SD card, USB stick, SSD, HDD) to have enough capacity for whatever you plan to do. This is not to say that the database *has* to be stored on the Pi. One can use remote databases, so it could be stored--rather literally--anywhere. It's just more common to store the data and run the database engine on the local system. I have, for instance, a pair of machines that run MySQL. One of them is a "hot backup" (reliability and data integrity are very important for the system in question) for the other and does that by running in slave mode, replicating everything that happens to the database on the master machine.
2. Yes. Personally, I used the "mysql" command, in the form of "mysql -p -D <database>" and then type in SQL commands to retrieve, update and delete data from tables as needed. There is also a GUI access (that I've never figured out...but I'm comfortable in a command line environment, so I didn't put that much effort into it) called "phpmysqladmin" (IIRC).
3. It will use as much memory as it needs, subject to physical and OS limits. Don't be concerned about memory usage. If you think you're going to be building large databases (and it doesn't sound like it), put your concerns into how much mass storage space you have.
4. If the database runs the filesystem of of space, pretty much everything is going to come to a halt because *nothing* will be able to write new data...including logging functions of the OS. To give you an idea... I run a convention registration system which probably has far bigger row sizes than you are planning to deal with. I use a separate database for each year. I have data going back to 2003 (it's an annual convention). We get about 1800 members each year. A backup file (mysqldump) of all databases is now up to 8.3MB. I have the systems running on a 60GB SSDs. I won't live long enough to fill that up. You will be writing more, but smaller, table rows. So long as you have a few GB of free space on the root device, you aren't likely to have a problem.