I'm a beginning sqlite user (v3.5.8 for Linux). I use a c++ program to open a connection to my database with no issues, but when trying to exec any sql statements after that, i get SQLITE_BUSY (i.e. database is locked). Here is the code I use:
int main() { sqlite3 *db; int ret; // Return value of sqlite3 calls string dbName = "emails.db"; // Database name char *zErrMsg; // Open a connection to the database ret = sqlite3_open(dbName.c_str(), &db); if (ret) { cout << "Can't open database: " << sqlite3_errmsg(db) << endl; sqlite3_close(db); exit(1); } string stmt = "CREATE TABLE IF NOT EXISTS"; string cols = "Received (Sender varchar(80), Receiver varchar(80), Subject varchar(512), Message varchar(512))"; stmt = stmt + " " + cols; ret = sqlite3_exec(db, stmt.c_str(), callback, 0, &zErrMsg); if (ret != SQLITE_OK) { cout << "SQL error: " << zErrMsg << endl; sqlite3_free(zErrMsg); } sqlite3_close(db); } // Based on the example code provided at www.sqlite.org 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; } Even if I change the sql statement, I always get SQLITE_BUSY. This is frustrating because this is a single-threaded app, so I have no idea why the database would be locked, especially before I have called any write operations to it (i.e. before a CREATE, INSERT, etc). Any ideas as to why this is happening and how I can fix it? Thanks. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users