SQLite Forum

C api sqlite3_db_readonly returns -1
Login
Note differences in below code from your's:<code>
  #include \<stdio.h\>
  #include "sqlite3.h"
  #define DBF "/tmp/my_dbfile.sdb"
  #define MAIN_SCHEMA "main"
int main(int an, char \*ap\[\]){
  sqlite3\* db;
  const char* values\[4\] = {"Ana","str","0720", "ana.oa"};
  char\* sql;
  int rc;
  sqlite3_stmt\* stmt;
  rc = sqlite3_open_v2(DBF, &db, SQLITE_OPEN_READWRITE, NULL );
  printf("%d\\n",rc);
  printf("%d\\n", sqlite3_db_readonly(db, MAIN_SCHEMA)); /\* Arg 2 changed \*/
  sql = "insert into ids (name, adr, tel, email) values(?1, ?2, ?3, ?4);";
  sqlite3_prepare_v2(db, sql, -1, &stmt, NULL );
  /\* C indices used for next 4 statements. \*/
  sqlite3_bind_text(stmt, 1, values[0], -1, SQLITE_STATIC);
  sqlite3_bind_text(stmt, 2, values[1], -1, SQLITE_STATIC);
  sqlite3_bind_text(stmt, 3, values[2], -1, SQLITE_STATIC);
  sqlite3_bind_text(stmt, 4, values[3], -1, SQLITE_STATIC);
  sqlite3_step(stmt);
  sqlite3_finalize(stmt);
  sqlite3_close(db);
  return 0;
}
/* Compile with: gcc -I. -o dbro /tmp/dbro.c sqlite3.c -lpthread -ldl -lm
*/
</code>