Hi All
I am trying to port sqlite3 VFS implementation on freertos(FATFS on stm32 ARM
CortexM4). I have created an amalgamation with sqlite3 version 3.12 base code.
When I run the below code it runs to create a database and a query "create a
table cars". But when query "insert" is run then fails with following error:-
error no: 26(SQLITE_NOTADB)
error: "file is encrypted or is not a database"
I have given following options during compile:
SQLITE_THREADSAFE=0
SQLITE_OS_OTHER=1
SQLITE_OMIT_WAL=1
Any pointer would really help.
Have a sample code as below:
sqlite3 *db = NULL;
char *zErrMsg = 0;
int rc;
char *sql;
rc = sqlite3_vfs_register(sqlite3_demovfs(), 1); /* Register a VFS */
if(rc != SQLITE_OK)
{
abort();
}
rc = sqlite3_open_v2("testsql.db", &db, SQLITE_OPEN_READWRITE |
SQLITE_OPEN_CREATE , "demo" );/* Create a SQL table */
if( rc )
{
abort();
}
sql = "PRAGMA journal_mode=OFF";/* Create SQL statement */
rc = sqlite3_exec(db, sql, NULL, NULL, &zErrMsg);/* Execute SQL
statement */
if( rc != SQLITE_OK )
{
sqlite3_free(zErrMsg);
abort();
}
sql ="CREATE TABLE Cars(Id INT, Name TEXT, Price INT);" ;/* Create SQL
statement */
rc = sqlite3_exec(db, sql, NULL, NULL, &zErrMsg);/* Execute SQL
statement */
if( rc != SQLITE_OK )
{
sqlite3_free(zErrMsg);
abort();
}
sql = "INSERT INTO Cars VALUES(1, 'Audi', 52642);"/* Create SQL
statement */
"INSERT INTO Cars VALUES(2, 'Skoda', 9000);";
rc = sqlite3_exec(db, sql, NULL, NULL, &zErrMsg);/* Execute SQL
statement */
if( rc != SQLITE_OK )
{
sqlite3_free(zErrMsg);
abort();
}
sql = "SELECT * from Cars";/* Create SQL statement */
const char* data = "Callback function called";
rc = sqlite3_exec(db, sql, callback, (void *)data, &zErrMsg);/* Execute
SQL statement */
if( rc != SQLITE_OK )
{
sqlite3_free(zErrMsg);
abort();
}
sqlite3_close(db);
DISCLAIMER
==========
This e-mail may contain privileged and confidential information which is the
property of Persistent Systems Ltd. It is intended only for the use of the
individual or entity to which it is addressed. If you are not the intended
recipient, you are not authorized to read, retain, copy, print, distribute or
use this message. If you have received this communication in error, please
notify the sender and delete all copies of this message. Persistent Systems
Ltd. does not accept any liability for virus infected mails.