[PLUG] Raspbian sqlite project...

Russell Senior russell at personaltelco.net
Wed Mar 22 05:27:14 UTC 2017


>>>>> "Michael" == Michael Christopher Robinson <michael at robinson-west.com> writes:

Michael> I'm wondering how to count the number of rows in the database
Michael> I'm creating from a C program.  The database has a row number
Michael> or Id that is the primary key.  I need to know how many rows
Michael> there are to know the next row number so I can add more
Michael> temperatures to the database.  I'm developing on a Raspberry Pi
Michael> 3 Model B 2016.  I have six USB temperature sensors hooked up
Michael> that I read from in a loop.  I generate a timestamp using
Michael> time.h and step through the six sensors.  Each sensor has an
Michael> internal temperature and an external temperature.

Michael> Table is like so:

Michael> id, sensor, timestamp, temp_inner, temp_outer.

Michael> With data types:

Michael> Integer, Integer, Integer, float, float.

Michael> If I can't get a row count in the C program, I have to pass it
Michael> in every time I do another round of readings.  I'm using
Michael> sqlite3.h for database access and manipulation.

Michael> I've been trying to answer this question on my own, but finding
Michael> sample C code that does this is not proving to be easy.

Why don't you make the (sensor,timestamp) combination the primary key instead?



-- 
Russell Senior, President
russell at personaltelco.net



More information about the PLUG mailing list