On Sun, 4 Oct 2009 12:11:52 +0700, Andi Suhandi <andisuha...@gmail.com> wrote:
>Hi George, > > >Thanks for the link >(http://www.codeproject.com/KB/database/CppSQLite.aspx) that you gave >me, it really help me to start progamming in C++. > >Ok, read the code in http://www.sqlite.org/quickstart.html, but it >looks like no SEE implementation. > >#include <stdio.h> >#include <sqlite3.h> > >static int callback(void *NotUsed, int argc, char **argv, char **azColName){ > int i; > for(i=0; i<argc; i++){ > printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL"); > } > printf("\n"); > return 0; >} > >int main(int argc, char **argv){ > sqlite3 *db; > char *zErrMsg = 0; > int rc; > > if( argc!=3 ){ > fprintf(stderr, "Usage: %s DATABASE SQL-STATEMENT\n", argv[0]); > exit(1); > } > > rc = sqlite3_open(argv[1], &db); > if( rc ){ > fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db)); > sqlite3_close(db); > exit(1); > } > rc = sqlite3_exec(db, argv[2], callback, 0, &zErrMsg); > if( rc!=SQLITE_OK ){ > fprintf(stderr, "SQL error: %s\n", zErrMsg); > sqlite3_free(zErrMsg); > } > sqlite3_close(db); > return 0; >} > > > >Ok, Since The SEE includes two new APIs: > > int sqlite3_key( > sqlite3 *db, /* The connection from sqlite3_open() */ > const void *pKey, /* The key */ > int nKey /* Number of bytes in the key */ > ); > > int sqlite_rekey( > sqlite *db, /* Database to be rekeyed */ > const void *pKey, int nKey /* The new key */ > ); > >So, if I want to connect/open database have to call sqlite3_key() >before sqlite3_open(argv[1], &db) function : > >..... > sqlite3_key(db,..,...); > > rc = sqlite3_open(argv[1], &db); > if( rc ){ > fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db)); > sqlite3_close(db); > exit(1); > } >..... > >Am I right ? No, you are wrong. http://www.hwaci.com/sw/sqlite/see.html says: The sqlite3_key() interface is used to specify the encryption key on a newly opened database connection. The comment states: >int sqlite3_key( > sqlite3 *db, /* The connection from sqlite3_open() */ So, first open(), then key() -- ( Kees Nuyt ) c[_] _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users