Newbie89 Posted May 8, 2013 Share Posted May 8, 2013 (edited) How to store data for 1 minute then update the database?any idea to do it?using sqlite and c language...is it just use delete and insert query to make it? Edited May 8, 2013 by Newbie89 Link to comment Share on other sites More sharing options...
justsomeguy Posted May 8, 2013 Share Posted May 8, 2013 You can delete and then insert, or use update. Is that your question? Link to comment Share on other sites More sharing options...
Newbie89 Posted May 9, 2013 Author Share Posted May 9, 2013 You can delete and then insert, or use update. Is that your question?yup,that's what I mean Link to comment Share on other sites More sharing options...
Newbie89 Posted May 9, 2013 Author Share Posted May 9, 2013 Can some help me check and recorrect my code? if (T_Time >= InTime){if (cal_count<60){printf("insert data till one minute\n");sprintf(sql_lite, "insert into Packet (Dated,Time,Src_MAC,Dest_MAC,Net_P,Trans_P,Src_IP, Dest_IP,Src_Port,Dest_Port,Cap_Bytes) values ('%s','%s','%s','%s','%s','%s','%s','%s','%ld','%l d','%ld');",DT, TM, Src_MAC, Dest_MAC, Net_P,Trans_P, Src_IP, Dest_IP, Src_Port, Dest_Port, Cap_Bytes);error = sqlite3_exec(conn, sql_lite, 0, 0, 0);cal_count=cal_count+1;}else{printf("update each one minute\n");sprintf(del_lite,"delete from Packet;");error = sqlite3_exec(conn, del_lite, 0, 0, 0);/*printf("Date=%s\tTime=%s\nSrc_MAC=%s\tDest MAC=%s\nNet_P=%s\tTrans_P=%s\nSrc_IP=%s\tDest_IP=% s\nSrc_Port=%ld\tDest_Port=%ld\nPacket Size=%ld\n", DT, TM, Src_MAC, Dest_MAC, Net_P,Trans_P, Src_IP, Dest_IP, Src_Port, Dest_Port, Cap_Bytes);*/sleep(1);}}elsebreak; I try and found that something wrong in my code.In my code just for one minute to keep data.How do I keep data for each 1 minute? Link to comment Share on other sites More sharing options...
justsomeguy Posted May 9, 2013 Share Posted May 9, 2013 There's not enough code there to suggest anything to change. Your question is how to get your program to wait a minute to do something else? I assume you don't just want the program to sleep for that minute, correct? Link to comment Share on other sites More sharing options...
Newbie89 Posted May 10, 2013 Author Share Posted May 10, 2013 There's not enough code there to suggest anything to change. Your question is how to get your program to wait a minute to do something else? I assume you don't just want the program to sleep for that minute, correct? Ya,I don't want the program to sleep for that minute.I want it perform repeatably like insert,delete,insert,delete... Link to comment Share on other sites More sharing options...
justsomeguy Posted May 10, 2013 Share Posted May 10, 2013 You'll need to have a variable that keeps track of the time of the last operation, and in your main loop you would check if 60 seconds or more has passed since that timestamp. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now