I am using sqlite3 version 2.8.17 on an Arm Debian Linux system.
I created a test table using these commands from Linux:
"
cat 01_create_tables.sql
CREATE TABLE PV_INTERVALDATA (
timestamp DATE,
T_ambient REAL NOT NULL,
T_trunk1 REAL NOT NULL,
T_trunk4 REAL NOT NULL
);
sqlite < 01_create_tables.sql pvintervaldata.sqlite
"
I then went to insert a row into the new database with this C code:
"
#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;
rc = sqlite3_open("pvintervaldata.sqlite", &db);
if( rc ){
fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
sqlite3_close(db);
return(1);
}
rc = sqlite3_exec(db, "insert into PV_INTERVALDATA
values(datetime('now','localtime'), 24.5, 20, 21);", callback, 0, &zErrMsg);
if( rc!=SQLITE_OK ){
fprintf(stderr, "SQL error: %s\n", zErrMsg);
sqlite3_free(zErrMsg);
}
sqlite3_close(db);
return 0;
}
"
On running the C program I get this error however:
"
SQL error: file is encrypted or is not a database
"
What is going wrong?
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users