On Sun, May 25, 2014 at 5:07 PM, Fred Basset <fredbasset1...@gmail.com>wrote:

> I am using sqlite3 version 2.8.17 on an Arm Debian Linux system.
>

SQLite version 2 and version 3 have incompatible file formats.  You appear
to have created a database using version 2 then tried to read that database
using version 3.

You should use SQLite version 3 exclusively.  SQLite 3 has been the
standard for 10 years.  SQLite3 is used for everything.  Nobody has used
SQLite2 in a very, very long time.



>
> 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
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>



-- 
D. Richard Hipp
d...@sqlite.org
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to