Ideally the database would be using a sequence for the ID. That way you don’t have to worry about it. You should be able to run an SQL query. I suspect what you need is here: http://stackoverflow.com/questions/13083199/sqlite3-c-api-number-of-rows
> On Mar 21, 2017, at 11:01 PM, Michael Christopher Robinson > <[email protected]> wrote: > > I'm wondering how to count the number of rows in the database I'm > creating from a C program. The database has a row number or Id that > is the primary key. I need to know how many rows there are to know the > next row number so I can add more temperatures to the database. I'm > developing on a Raspberry Pi 3 Model B 2016. I have six USB > temperature sensors hooked up that I read from in a loop. I generate a > timestamp using time.h and step through the six sensors. Each sensor > has an internal temperature and an external temperature. > > Table is like so: > > id, sensor, timestamp, temp_inner, temp_outer. > > With data types: > > Integer, Integer, Integer, float, float. > > If I can't get a row count in the C program, I have to pass it in every > time I do another round of readings. I'm using sqlite3.h for database > access and manipulation. > > I've been trying to answer this question on my own, but finding sample > C code that does this is not proving to be easy. > _______________________________________________ > PLUG mailing list > [email protected] > http://lists.pdxlinux.org/mailman/listinfo/plug > > -- Louis Kowolowski [email protected] Cryptomonkeys: http://www.cryptomonkeys.com/ Making life more interesting for people since 1977
signature.asc
Description: Message signed with OpenPGP using GPGMail
_______________________________________________ PLUG mailing list [email protected] http://lists.pdxlinux.org/mailman/listinfo/plug
