Re: [sqlite] Issue "sqlite database locked"

2010-03-26 Thread D. Richard Hipp

On Mar 26, 2010, at 12:40 AM,  
 wrote:

> Hi,
>
>
> I have downloaded the sqlite from the link 
> http://www.sqlite.org/download.html 
>  version sqlite-3.6.23.so.gz sqlite-3.6.23.so.gz> (220.62 KiB). I am using fedora -9-i386. Have  
> mounted a
> Shared drive on my pc to the fedora image.I copied the extracted  
> sqlite db and saved it on the fedora usr/lib directory from where  
> the code loads the db.

Please see the second paragraph of http://www.sqlite.org/faq.html#q5  
for a likely explanation of what is going wrong.


>
> This is the piece of code that I am using to do the operations on  
> sqlite db.
>
> #include 
> #include "sqlite3.h"
> #include 
>
> using namespace std;
>
> typedef void* HINSTANCE;
>
> typedef int (*FnPtr_sqlite3_open)(const char *filename, sqlite3  
> **ppDb );
> typedef int (*FnPtr_sqlite3_extended_result_codes) (sqlite3*, int  
> onoff);
> typedef int (*FnPtr_sqlite3_prepare_v2)(sqlite3 *db, const char  
> *zSql, int nByte, sqlite3_stmt **ppStmt, const char **pzTail );
> typedef int (*FnPtr_sqlite3_step)(sqlite3_stmt*);
> typedef int (*FnPtr_sqlite3_finalize)(sqlite3_stmt *pStmt);
>
> class TDBClass
> {
> public:
>HINSTANCE LoadLibrary();
>void LoadFunctions();
>void VerifyLoadedFunction(void* aFnPtr);
> public:
>FnPtr_sqlite3_open  sqlite3_open;
>FnPtr_sqlite3_extended_result_codes  
> sqlite3_extended_result_codes;
>FnPtr_sqlite3_prepare_v2sqlite3_prepare_v2;
>FnPtr_sqlite3_step  sqlite3_step;
>FnPtr_sqlite3_finalize  sqlite3_finalize;
>
>HINSTANCE sqLiteHndl;
> };
>
>
> HINSTANCE TDBClass::LoadLibrary()
>{
>sqLiteHndl = dlopen("/usr/lib/sqlite-3.6.23.so", RTLD_LAZY| 
> RTLD_GLOBAL);
>return sqLiteHndl;
>}
>
> void* GetProcAddress(HINSTANCE aHandle, const char* aSymbol)
>{
>return dlsym(aHandle, aSymbol);
>}
>
> void TDBClass::LoadFunctions()
>{
>sqlite3_open =  
> (FnPtr_sqlite3_open)GetProcAddress(sqLiteHndl,"sqlite3_open");
>if(sqlite3_open== NULL)
>{
>return;
>}
>sqlite3_prepare_v2  = (FnPtr_sqlite3_prepare_v2)  
> GetProcAddress(sqLiteHndl,"sqlite3_prepare_v2");
>sqlite3_step= (FnPtr_sqlite3_step)  
> GetProcAddress(sqLiteHndl,"sqlite3_step");
>sqlite3_extended_result_codes =  
> (FnPtr_sqlite3_extended_result_codes) GetProcAddress(sqLiteHndl,  
> "sqlite3_extended_result_codes" );
>}
>
>
>
> int main()
>{
>cout << "!!!Hello World!!!" << endl; // prints !!!Hello  
> World!!!
>
>sqlite3* sqlhandle;
>TDBClass tdbhandle;
>HINSTANCE sqlitehandle = tdbhandle.LoadLibrary();
>tdbhandle.LoadFunctions();
>int err = tdbhandle.sqlite3_open("/root/Sudha/epoc32/winscw/c/ 
> tswi/tscrtool/scr.db",&sqlhandle);
>err = tdbhandle.sqlite3_extended_result_codes(sqlhandle, 0);
>sqlite3_stmt* stmtHandle = NULL;
>const char* stmtTail = NULL;
>
>const char* statement = "CREATE TABLE  
> SoftwareTypeNames(NameId INTEGER PRIMARY KEY NOT NULL,SoftwareTypeId  
> INTEGER NOT NULL,Locale INTEGER DEFAULT 0,Name TEXT NOT NULL);";
>std::string stmt(statement);
>tdbhandle.sqlite3_prepare_v2(sqlhandle, stmt.c_str(),  
> stmt.size(), &stmtHandle, &stmtTail);
>int err1 = tdbhandle.sqlite3_step(stmtHandle);
>
>return 0;
>}
>
>
> This step int err1 = tdbhandle.sqlite3_step(stmtHandle);
> in the code returns 5 (sqlite_busy) every time I run the program.
> (I don't have any multi threads in my program which can lock the db. )
>
> Any help on this is appreciated.
>
>
> Regards
> sudha
>
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

D. Richard Hipp
d...@hwaci.com



___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Issue "sqlite database locked"

2010-03-26 Thread sudha.bheemanna
Hi,


I have downloaded the sqlite from the link http://www.sqlite.org/download.html 
version sqlite-3.6.23.so.gz (220.62 
KiB). I am using fedora -9-i386. Have mounted a
Shared drive on my pc to the fedora image.I copied the extracted sqlite db and 
saved it on the fedora usr/lib directory from where the code loads the db.

This is the piece of code that I am using to do the operations on sqlite db.

#include 
#include "sqlite3.h"
#include 

using namespace std;

typedef void* HINSTANCE;

typedef int (*FnPtr_sqlite3_open)(const char *filename, sqlite3 **ppDb );
typedef int (*FnPtr_sqlite3_extended_result_codes) (sqlite3*, int onoff);
typedef int (*FnPtr_sqlite3_prepare_v2)(sqlite3 *db, const char *zSql, int 
nByte, sqlite3_stmt **ppStmt, const char **pzTail );
typedef int (*FnPtr_sqlite3_step)(sqlite3_stmt*);
typedef int (*FnPtr_sqlite3_finalize)(sqlite3_stmt *pStmt);

class TDBClass
{
public:
HINSTANCE LoadLibrary();
void LoadFunctions();
void VerifyLoadedFunction(void* aFnPtr);
public:
FnPtr_sqlite3_open  sqlite3_open;
FnPtr_sqlite3_extended_result_codes sqlite3_extended_result_codes;
FnPtr_sqlite3_prepare_v2sqlite3_prepare_v2;
FnPtr_sqlite3_step  sqlite3_step;
FnPtr_sqlite3_finalize  sqlite3_finalize;

HINSTANCE sqLiteHndl;
};


HINSTANCE TDBClass::LoadLibrary()
{
sqLiteHndl = dlopen("/usr/lib/sqlite-3.6.23.so", RTLD_LAZY|RTLD_GLOBAL);
return sqLiteHndl;
}

void* GetProcAddress(HINSTANCE aHandle, const char* aSymbol)
{
return dlsym(aHandle, aSymbol);
}

void TDBClass::LoadFunctions()
{
sqlite3_open = 
(FnPtr_sqlite3_open)GetProcAddress(sqLiteHndl,"sqlite3_open");
if(sqlite3_open== NULL)
{
return;
}
sqlite3_prepare_v2  = (FnPtr_sqlite3_prepare_v2) 
GetProcAddress(sqLiteHndl,"sqlite3_prepare_v2");
sqlite3_step= (FnPtr_sqlite3_step) 
GetProcAddress(sqLiteHndl,"sqlite3_step");
sqlite3_extended_result_codes = (FnPtr_sqlite3_extended_result_codes) 
GetProcAddress(sqLiteHndl, "sqlite3_extended_result_codes" );
}



int main()
{
cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!

sqlite3* sqlhandle;
TDBClass tdbhandle;
HINSTANCE sqlitehandle = tdbhandle.LoadLibrary();
tdbhandle.LoadFunctions();
int err = 
tdbhandle.sqlite3_open("/root/Sudha/epoc32/winscw/c/tswi/tscrtool/scr.db",&sqlhandle);
err = tdbhandle.sqlite3_extended_result_codes(sqlhandle, 0);
sqlite3_stmt* stmtHandle = NULL;
const char* stmtTail = NULL;

const char* statement = "CREATE TABLE SoftwareTypeNames(NameId INTEGER 
PRIMARY KEY NOT NULL,SoftwareTypeId INTEGER NOT NULL,Locale INTEGER DEFAULT 
0,Name TEXT NOT NULL);";
std::string stmt(statement);
tdbhandle.sqlite3_prepare_v2(sqlhandle, stmt.c_str(), stmt.size(), 
&stmtHandle, &stmtTail);
int err1 = tdbhandle.sqlite3_step(stmtHandle);

return 0;
}


This step int err1 = tdbhandle.sqlite3_step(stmtHandle);
 in the code returns 5 (sqlite_busy) every time I run the program.
(I don't have any multi threads in my program which can lock the db. )

Any help on this is appreciated.


Regards
sudha

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users