[sqlite] How to run sqlite just in memory - pragma cache_size issue
Hi, Richard, Thanks for the advice, I have look at the link and experiment with it. The example loadOrSaveDb is pretty clear and straightforward. However I did not get it working with the following example: sqlite3 *db; char *zErrMsg = 0; void main(void) { int rc; char oph_sql_db[32], oph_sql_bk[32], s[10]; strcpy(oph_sql_db, "oph.bk3"); strcpy(oph_sql_bk, "oph.sav"); rc = sqlite3_open(":memory:", ); if( rc!=SQLITE_OK ) fprintf(stderr, "ER! - Open in Memory DB : %s\n", zErrMsg); else printf("\nOpen Memory DB ok\n"); rc=loadOrSaveDb(, oph_sql_db, 0); if( rc!=SQLITE_OK ) fprintf(stderr, "ER! - Load DB from disk to Memory : %s\n", zErrMsg); else printf("\nLoad DB ok\n"); printf("\nHit any key + return to save back to hard disk\n"); scanf("%s", s); rc=loadOrSaveDb(, oph_sql_bk, 1); if( rc!=SQLITE_OK ) fprintf(stderr, "ER - Save in Memory to disk : %s\n", zErrMsg); else printf("\nSave Memory ok\n"); } it reports that the "Open Memory DB OK" and the other two statements return with NOT SQLITE_OK. Further more, if I open the DB normally and just call to save a backup copy, it actually save the db onto hard disk with file of identical size but it also return NOT SQLITE_OK. I am using sqlite 3.7.9 on Linuxmint, as I can not see any obvious reason for reporting error I am wondering could it be an issue of sqlite version? Please advice, thanks. kfl (Hong Kong). -- --- ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
[sqlite] How to run sqlite just in memory - pragma cache_size issue
Hi, I use sqlite (v3.7.9) in a Linuxmint environment to act as gateway for, on one side, a dozen of users give control request via TCPIP, Bluetooth HTTP and Linux Pipe. On the other side, via RS232 and Zigbee to control some 30 devices according to the request. All activities, user requests and device feedback are written to the database which is about 2.5MB and the entry is at about one database read/write in one/two seconds. The size of database will not increase as a fixed amount of entries are stayed in the database, all other written to text log file. I have tried to use: pragma cache_size=3000 and executed the statement after database has been opened. My understanding is that this statement would give 3MB cache size to keep all data in the memory and reduced hard disk access. However the hard disk access seem still there with disk hamming rise up and down when write to database. Perhaps I misunderstood what pragma cache does, please advice. I have also explored the possbility of open database in :Memory: but could not find how this would be linked to the hard disk database. Are there facilities to open a hard disk database and keep all in memory, operate the memory db using normal sqlite statements, and later save it back to hard disk? That sound like a perfect solution. kfl. (Hong Kong). -- ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users