Home

Examples

Download

Documentation

Changelog

Guestbook

Contact


Write a guestbook entry:

Name:
e-mail address:
Show e-mail address public?
Entry:
Spam Protection: Arithmetic Problem: 7 math 3 - 2 =
 
 
 


  JPlaroche 10:00  09.03.2018  
Is Ok SQLite3 3.22

change compilelation

SQLITE_ENABLE_COLUMN_METADATA

example :

CFLAGS= -Wall -O3 -Os -w -std=c++17 -fpermissive -fPIC -DSQLITE_ENABLE_COLUMN_METADATA

LDFLAGS= -lpthread -lctemplate -pthread



votre lib vas bien ce compiler mais vous ne pourrez pas l'utiliser si vous ne rajoutez pas lors de votre fabrication de votre lib
-DSQLITE_ENABLE_COLUMN_METADATA -pthread
 
  EricB 21:06  10.02.2018  
I've been using Kompex for a long while in my project. It's great! Thank you so much for it.

Occasionally I will update the sqlite used by the lib to the latest versions. The most recent attempt at this, I upgraded from 3.17 to 3.22.

Everything is working great in Windows and OSX. But Linux is having linking problems. Undefined References when I try to link the resulting Kompex Lib with my program. 3.17 works, 3.18 and newer does not.

Any chance we'll get an updated sqlite with Kompex soon? The performance increases with the lasted builds are awesome!
 
  Crazy8   |   E-Mail: iDig.crazy8@fakemail.com 18:23  25.02.2017  
Just came by to say: thank you

// Comment by Sven:
// :D
 
  Ratin   |   E-Mail: ratin3@gmail.com 21:10  30.09.2016  
I am dealing with memory database. The problem I am seeing is if the DB is updated externally (like with php), and rows are inserted/updated by that, I dont see the changes from C++ environment. I tried many different things but to no avail. Any idea?
 
  Ratin   |   E-Mail: ratin3@gmail.com 21:05  25.07.2016  
Hi, Excellent C++ integration API for sqlite! Everything works as is, except when I load the app that uses Kompex api to talk to the database, I can't change the DB via shell scripts or the interactive shell, all inserts/updates fail with the message "Error: database is locked". Is there a mode to make the DB editable while the app is running in the background?
 
  jp 11:05  06.05.2016  
serpentus REGARD:

pStmt->FreeQuery();
pDatabase->Close();
 
  Roy SHANG   |   E-Mail: shangzuoyan@gmail.com 07:35  06.05.2016  
Hi,

Can I make multi-statement objects with one connection.
I linked this library to a multi-thread application.

I need a readonly statement object and readwrite statement object with the same datebase file connection.


Thanks
Roy
 
  JP 02:32  16.04.2016  
I'm back as well in evolution



and if you was including

#include <sys/stat.h>
bool database_open(const char * Dbase)
{

struct stat fileInfo;

if(stat(Dbase, &fileInfo) == 0 ) { return true; }

fprintf(stderr, "Can't open database: %s\n",Dbase);

return false;
}


bool database_delete(const char * Dbase)
{
struct stat fileInfo;
if(stat(Dbase, &fileInfo) == 0 ) { remove( Dbase ); return true; }

fprintf(stderr, "Can't open database: %s\n",Dbase);

return false;
}
 
  ColinG 11:40  13.12.2015  
Using your wrapper in a small investment app for home use and its great!
I had a slight problem where sqlite3 stopped working properly (lost the db file missing or invisible?) but rebuilt that and it all works together ok now.
Thanks a lot.
 
  Serpentus 21:43  08.12.2015  
A couple of bugs.

(1)
try
{
Kompex::SQLiteDatabase DB;
Kompex::SQLiteStatement Stmt(&DB);
DB.Open(...);
// A query. All OK
Stmt.Sql(L"SELECT * FROM mytable");
// Forgot to call Stmt.FreeQuery()
// An other query.
Stmt.Sql(L"SELECT * FROM mytable");
// No exception thrown here!
Stmt.FreeQuery();
// Still no exception
DB.Close();
// Only now exception is thrown.
// It's very hard to understand, where is an error in my code.
}
catch(...)
{
}

(2) But it's even worse:
// KompexSQLiteDatabase.cpp
SQLiteDatabase::~SQLiteDatabase()
{
Close();
}
Look code (1) again: SQLiteDatabase::Close() throws exception from destructor and that leads to process termination by abort() call, exception will not be catched.
 
  marc 13:16  07.10.2015  
sorry...
found error

pragma foreign_keys;
0

)

// Comment by Sven:
// I'm glad you could find the error.
 
  marc 12:25  07.10.2015  
Hi!

Have 2 tables (personality and groups):

[personality]
integer pid; // PRIMARY UNIQUE AUTOINCREMENT
integer gid; // REFERENCES groups (gid) ON DELETE CASCADE
// ON UPDATE CASCADE
// MATCH SIMPLE
varchar name;
...

[groups]
integer gid; // PRIMARY UNIQUE AUTOINCREMENT
varchar name;

and code:
void DB::delete_group_record (gint gid)
{
Kompex::SQLiteStatement *pStmt = new Kompex::SQLiteStatement(&db);
ustring statmnt = ustring::compose ("DELETE FROM groups WHERE gid = %1", gid);
pStmt->BeginTransaction();
pStmt->Transaction (statmnt);
pStmt->CommitTransaction();
delete pStmt;
}

after execute this code record from [groups] table will be deleted, but [personality] records stayed unchanged. If execute interactive sql command "DELETE FROM groups WHERE gid = 5" changes affect both tables.
What could be wrong?
 
  Leon 09:46  03.08.2015  
Hi Sven,
You had said that "Use the Sql() and Bind*() methods between BeginTransaction() and CommitTransaction()." I wonder if it's necessary to use Execute() or ExecuteAndFree() before Commit?

// Comment by Sven:
// Hi Leon,
// It is necessary to use Execute() or ExecuteAndFree() before you use COMMIT.
// Otherwise you would get the error message "unable to close due to unfinalized
// statements or unfinished backups".
 
  Robo 20:18  23.05.2015  
Main problem in VS2010 is taht, when I close db
in this way
delete pStmt;delete pDatabase;
I obtain exception. Help me how to close db pls.

"Unhandled exception at 0x76b9c41f in Kompex SQLite Example.exe: Microsoft C++ exception: Kompex::SQLiteException at memory location 0x001ce954.."

// Comment by Sven:
// Please use a try/catch block around your source code in order to get
// a proper error message. After that it should be quite easy to understand
// and solve the problem.
 
  mao 17:20  08.04.2015  
Please can you show me an example to use your wrapper as dll in a mfc windows app ?
Thank you.

// Comment by Sven:
// The usage of the wrapper does not differ between MFC
// applications and other kinds of applications. Furthermore, I do
// not have such an example at hand. Sorry.
 
  Chuck 22:45  12.02.2015  
I'm trying to integrate into a C++ DLL project but am running into unresolved external linking issues. It seems it's due to name mangling.

Thanks for any help

See below:

EventManager.obj : error LNK2019: unresolved external symbol "public: __cdecl Kompex::SQLiteStatement::SQLiteStatement(class Kompex::SQLiteDatabase *)" (??0SQLiteStatement@Kompex@@QEAA@PEAVSQLiteDatabase@1@@Z) referenced in function "public: void __cdecl cEventManager::DumpEventsToDebug(void)" (?DumpEventsToDebug@cEventManager@@QEAAXXZ)
EventManager.obj : error LNK2019: unresolved external symbol "public: __cdecl Kompex::SQLiteDatabase::SQLiteDatabase(char const *,int,char const *)" (??0SQLiteDatabase@Kompex@@QEAA@PEBDH0@Z) referenced in function "public: void __cdecl cEventManager::DumpEventsToDebug(void)" (?DumpEventsToDebug@cEventManager@@QEAAXXZ)

// Comment by Sven:
// Unfortunately, I don't know the solution. It seems to be a problem with wrong
// linker settings or missing libraries, so that I would check these settings.
 
  Leon 07:00  16.01.2015  
It seems the package contains sources of sqlite3 with version 3.8.4.3. How can I use my own libsqlite3.so which lies in /usr/local/lib?

// Comment by Sven:
// The source code of sqlite3 is included because the wrapper is build around this
// library and depends on it. Therefore, you can either use the wrapper library or
// the pure sqlite3 library. At most, you could download the sqlite3 dev package
// and modify the makefile of the wrapper.
 
  Leon 03:45  16.01.2015  
Does the wrapper support using "BEGIN IMMEDIATE" for Transaction?

// Comment by Sven:
// BEGIN IMMEDIATE is currently not supported. That is why DEFERRED is
// used by default. I'll investigate whether it is possible to add a parameter
// in BeginTransaction() so that the developer can choose the type of transaction.
 
  Amir 05:43  31.12.2014  
Hi, Thank you for such a nice library.
How can i bind something after calling Transaction?
Is is supported at all?

// Comment by Sven:
// In that case you can not use the method Transaction(). Just use BeginTransaction()
// and CommitTransaction() as always and use the Sql() and Bind*() methods between
// them. But do not forget to implement an own catch block (see example application).
 
  Mike 00:33  03.12.2014  
I love your library. Unfortunately, it looks like I'm confused about UTF-8. I was under the impression that you needed to store UTF-8 in wstring, but I've read that this is bad practice but a common error for all windows developers. Unfortunately, the libraries I have are all written in such a way that UTF-8 is always held in wstring. Do you have any advice for me?

Many thanks!
Mike

// Comment by Sven:
//
// Hi Mike,
// Unicode with its different encodings is a painful topic because C++ didn't provide any
// Unicode support in the past. Therefore, there exist a lot of different ways in order to
// use Unicode. Only the newest standard C++11 provides some Unicode support. But if I
// would use those features I would break a lot of older projects. I'll send you an URL
// with further explanations.
 
  littlelight 04:49  30.10.2014  
I was using Kompex sqlite wrapper in a DialogEx based application, Memory leak after Application closed.

sample code like below
void CTestDlg::OnBnclickTest()
{
// create and open database
Kompex::SQLiteDatabase *pDatabase = new Kompex::SQLiteDatabase("test.db", SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, 0);
// create statement instance for sql queries/statements
Kompex::SQLiteStatement *pStmt = new Kompex::SQLiteStatement(pDatabase);
// ---------------------------------------------------------------------------------------------------------
// create table and insert some data
pStmt->SqlStatement("CREATE TABLE user (userID INTEGER NOT NULL PRIMARY KEY, lastName VARCHAR(50) NOT NULL, firstName VARCHAR(50), age INTEGER, weight DOUBLE)");
pStmt->SqlStatement("INSERT INTO user (userID, lastName, firstName, age, weight) VALUES (1, 'Lehmann', 'Jamie', 20, 65.5)");

// ---------------------------------------------------------------------------------------------------------
// clean-up
delete pStmt;
delete pDatabase;

}

Memory leak info:
{440} normal block at 0x004E5FD0, 56 bytes long.
Data: < sY SN (`N > A0 13 73 59 00 00 00 00 B0 53 4E 00 28 60 4E 00
{439} normal block at 0x004E53B0, 68 bytes long.
Data: < sY est.db > B4 13 73 59 00 00 00 00 00 65 73 74 2E 64 62 00
It's seemed delete SQLiteDatebase and delete SQLiteStatement NOT release memory correctly.

Is my usage of Kompex sqlite wrapper wrong?


// Comment by Sven:
// Your usage of the wrapper is totally fine. I tested your source code and
// I didn't get any memory leak information. But maybe you cause an exception
// that will not be caught because of the missing try/catch block. In this case
// you might produce a memory leak.
 
  Pankaj Yadav   |   E-Mail: 2pankajy@gmail.com 06:45  14.08.2014  
Hi Sven,
Thanks for writing this wonderful wrapper. It helped me lot. I have a query regarding exception that I always getting while closing the database. Exception is "unable to close due to unfinalized statements or unfinished backups". I have checked for APIs like FreeQuery() and CleanUpTransaction() is calling properly at the end of transaction but why I am getting this exception?
Thanks,
Pankaj Yadav

// Comment by Sven:
//
// Hi Pankaj,
//
// You will get the mentioned exception message if the database handle can not be closed
// properly because you missed to clean up all internal sqlite stuff by using FreeQuery().
// Please check whether you clean up the internal sqlite stuff after each call of
// Sql()/FetchRow() and Execute() like in the example application. You could try to call
// FreeQuery() multiple times at the end of your source code and see what happens (just
// for testing purposes).
 
  Lonko 22:03  07.07.2014  
Dear Sven,

first of all excellent work!!! I needed to modify your source to avoid compiling std::wstring as i'm using this on an embedded device where wstring in uclibc is not supported. I put some #defines inside the source to solve the problem.

Now to my question:
1. do we need to use dynamic allocation of statements or db... ? can it be static defined ?
Kompex::SQLiteStatement *cmd = new Kompex::SQLiteStatement(db);
to this:
Kompex::SQLiteStatement cmd(db); is there any problem ? do dtors free up what is allocated internally?

Best r...


// Comment by Sven:
//
// Hi Lonko,
//
// Thank you. Yes, such modifications are necessary sometimes depending on
// the platform. Fortunately, the wrapper is open source and can be modified. :)
//
// You can use Kompex::SQLiteDatabase and Kompex::SQLiteStatement in both
// ways (i.e. creation on heap or stack). The dtors will clean up all internal stuff.
 
  Mario 23:12  18.06.2014  
Hi,
I found the problem it was caused by a memory leak in my GUI control and it crashed in the FetchReow(), so it seems that your code is ok. It took me 4 days to find out that the problem is not in sqlite/kompex.
I also want to congratulate you for this code, it really helps a lot working with sqlite, I don't know what I would do without this library.

// Comment by Sven:
// I'm happy to hear that you could solve your problem.
// Thank you for your feedback. :)
 
  Mario 16:10  13.06.2014  
pStmt->FetchRow() generates an exception when no records are returned, in debug works fine, but in release unicode x64 it crashes, so it cannot be debugged. :(

// Comment by Sven:
// FetchRow() does work even if no records are returned. I just tested a few scenarios to
// be on the safe side. If you want you can send me the exception message and/or an
// abstracted project with a test database. Then I could try to track down the problem.
 
  Mike 12:11  30.12.2013  
on Windows XP it crashes only at the second FetchRow() and there are 1600 results to process.
 
  Mike 12:06  30.12.2013  
I have a while(pStmt->FetchRow())
which works on windows 7 and on XP it always crashes in the fetchrow, and try catch does not catch any exception.

// Comment by Sven:
// Could you please send me a short example (source code + database) so that I
// can track down the problem?!
 
  John M. 02:12  10.10.2013  
Great work !
 
  pris 04:06  26.08.2013  
Hey. Thanks for the great lib. I had a quick question; is it possible to check whether or not a number type column entry has null value?

Pris

// Comment by Sven:
// Hi Pris,
// You can use SQLiteStatement::GetColumnType() to check whether a result contains a
// NULL value. But please note that sqlite will internally convert your NULL values
// to 0 (e.g. if you use SQLiteStatement::GetColumnInt()).
 
  mohamed amie sifi   |   E-Mail: mohamedamine.sifi@yahoo.fr 14:13  31.07.2013  
Hi ,
Please I want to know exactly how can I use the library , what database should I use and what are library includes and dependencies should I do , please someone help me and explain to me clearly the usage of Kompex SQLite Wrapper
 
  Gaurav 10:16  11.07.2013  
ok.
Here are some details :-

your code is :-

if(sqlite3_prepare_v2(mDatabase->GetDatabaseHandle(), sqlStatement, -1, &mStatement, 0) != SQLITE_OK)
KOMPEX_EXCEPT(sqlite3_errmsg(mDatabase->GetDatabaseHandle()));

the "error string" thrown is not the exact "error string" generated by using values returned by "sqlite3_prepare_v2" but the global last error message on the db. This is not SMP safe. Considering most of the apps are multithreaded, you could change the implementation. Just catch error code in a local and use it with APIs like "sqlite3ErrStr" etc.

Another point, people would like to know the actual error code of the operations instead of stupid string messages. You could add error code member to SQLiteException.
 
  Daniel 23:41  01.07.2013  
Hi,
are there examples for getting the total number of records in a Table and also incrementing X rows within a dbf using MFC?
Thanks in advance,
Daniel

// Comment by Sven:
// Hi Daniel,
// I think the following line should help you to get the total number of records:
// pStmt->SqlAggregateFuncResult("SELECT COUNT(*) FROM tableName");
// What do you mean with incrementing X rows within a dbf? Maybe we can
// discuss it via e-mail.
 
  Gaurav    |   E-Mail: gaurav.ak47@gmail.com 08:50  01.07.2013  
on studying the kompex wrapper it appears that it has some issues :-
1> error handling is done by using the global "most recent error message" on the sqlite db object this is not smp friendly
2> Also, there is no way to know if the statement failed due to syntax error
or foriegn key constraints etc. as no error code is returned. We only have stupid strings.
3> lack of such simple features makes me conclude that the library was designed by idiots

// Comment by Sven:
// It's a free piece of source code which was developed in my spare time. Furthermore,
// each library has been designed for special cases and you don't need to use it when it
// doesn't fit your needs. Additionally, you could provide a patch if you have found an
// issue or at least provide detailed information about the problem (if there is really one,
// probably you just used it in a wrong way..). But instead of providing helpful information
// you are just complaining and insulting me. You are a great developer!
 
  Daniel 02:05  28.06.2013  
Hi Sven,
a great wrapper for SQLite...it is very cool.
I am interested to read your comments on Sataya's question for saving Table Data into vectors if possible,
thanks in advance,
Daniel

// Comment by Sven:
//
// Hi Daniel,
// Below you will find my answer to Sataya's question. I hope it will help you.
//
// It is a little difficult to answer that question because there a lot of use cases.
// But I will try it in general way with the following example.
//
// std::vector<std::string> myVector;
// pStmt->Sql("SELECT * FROM user WHERE firstName = 'Jamie';");
// while(pStmt->FetchRow())
// {
// myVector.push_back(pStmt->GetColumnString(0));
// myVector.push_back(pStmt->GetColumnString(1));
// }
// pStmt->FreeQuery();
 
  netrick 19:25  24.02.2013  
Keep up the good work! I have been looking for something like that for ages, it makes coding MUCH easier!

// Comment by Sven:
// You're welcome! : )
 
  Aubr.Cool 09:00  22.01.2013  
brian Tee
I compiled this wrapper using arm-linux-g++ 4.4.1!
Change your arm-linux-g++ and try!
 
  brian Tee 05:54  20.01.2013  
Finally i able to build using g++-4.4 . I must build using g++-4.4 ? Because my development environment is embedded Linux, so must cross compile using arm g++ compiler . Any recommendation if i want to compile using arm g++ compiler and avoid the problem i stated below ?

// Comment by Sven:
// Please try to add -lpthread to the compiler commands.
 
  brian Tee 19:11  19.01.2013  
I use Netbean to build the source code downloaded.
First i build Kompex SQLite Wrapper , i see KompexSQLiteWrapper_Static_d.a file generated , then i build Kompex SQLite Example . I got the following error . Please help .

/sqlite3.c:18050: undefined reference to `pthread_mutexattr_init`
/sqlite3.c:18051: undefined reference to `pthread_mutexattr_settype`
/sqlite3.c:18053: undefined reference to `pthread_mutexattr_destroy'
(sqlite3.o): In function `pthreadMutexTry':
undefined reference to `pthread_mutex_trylock'
(sqlite3.o): In function `unixDlOpen':
undefined reference to `dlopen'
(sqlite3.o): In function `unixDlError':
undefined reference to `dlerror'
(sqlite3.o): In function `unixDlSym':
undefined reference to `dlsym'
(sqlite3.o): In function `unixDlClose':
undefined reference to `dlclose'

 
  Aubr.Cool   |   E-Mail: Aubr.Cool@gmail.com 03:24  16.01.2013  
Thank you for your codes, I want to use your codes in my programs . I has some questions to ask for you !
Will it has some memory leakage ?
In SQLiteDatabase Constructor calls open() which may throw an exception.
In SQLiteDatabase destructor calls close() which may throw two exceptions.
Will The up two situations may leave mDatabaseHandle not
free when these exceptions occur?

// Comment by Sven:
// @open() This is sqlite internal stuff. Therefore, I don't know exactly how they
// are handling errors cases. Please take a look in the sqlite open() function.
// @close() You would have a memory leak if you wouldn't react on the
// exceptions. Anyway, this should never happen in a productive application.
 
  brian tee 00:28  16.01.2013  
I intend to use this in embedded linux which doest support C compiler and G++ . So i need to Generate the library outside of my embedded linux and use it as library on embedded linux.
What is the step to create the Komplex SQLite in library for linux?

Thank you in advance.

// Comment by Sven:
// Please see the entry below.
 
  brian tee 00:18  16.01.2013  
Any document explaining how to install it on Linux?

Could you please let me know how I could make your code work on Linux ?

Thank you in advance.

// Comment by Sven:
// Please try to follow the instructions under the point "Linux in general" on
// the "Download" page. Otherwise, you could build the wrapper with NetBeans
// in order to copy the library files to your desired destination.
 
  Xianzhong Zhu 14:35  10.01.2013  
Hi Sven,
I received your e-mail.According to my understanding, you said the wrapper can run OK on Win7+VS2010 win32 desktop-styled applications (where the wrapper can serve typically as a .dll or .lib file). But what I concerned was directly putting your wrapper (the .cpp and .h files rather than in the form of .dll or .lib file) into the mobile app case. That's it.

Regards,

// Comment by Sven:
// This should be possible. You could also link the static library.
 
  Xianzhong Zhu 13:17  09.01.2013  
Hi,
In the first case - common Win7+VS2010 desktop styled applications, the demos can run OK. While in the second case, I really want to put your Sqlite wrapper into the mobile game enviornment (I am using cocos2d-x to develop android apps. NOTE: cocos2d-x is a compatible one for cocos2d under iPhone). I found in nearly all the following guest leaving words mobile cases were mentioned quite little. Anyway, thank you again for your quick reply and further study.

Regards,,

// Comment by Sven:
// Did you receive my e-mail?
 
  Xianzhong Again 10:24  05.01.2013  
The exception was thrown at:

pStmt->SqlStatement("CREATE TABLE user (userID INTEGER NOT NULL PRIMARY KEY, lastName VARCHAR(50) NOT NULL, firstName VARCHAR(50), age INTEGER, weight DOUBLE)");

And the related wrapper statement was:

if(sqlite3_prepare_v2(mDatabase->GetDatabaseHandle(), sqlStatement, -1, &mStatement, 0) != SQLITE_OK)
KOMPEX_EXCEPT(sqlite3_errmsg(mDatabase->GetDatabaseHandle()));

Thanks again.


// Comment by Sven:
// I've written you an e-mail because it seems that we need to investigate that.
 
  Xianzhong Zhu 10:08  05.01.2013  
Hi,
Thanks for such a good tool. I'm a personal developer from China and learning a cross-platform mobile 2D game SDK named cocos2d-x. I downloaded your latest release and found the sample project ran OK under VS2010+Windows7. However, when I tried to shift the .cpp and .h files to my cocos2d-x projects some exceptions were thrown out -'Unhandled exception at 0x75a09673 (KernelBase.dll) in HiKompexSQLite.win32.exe: Microsoft C++ exception: Kompex::SQLiteException at memory location 0x0039f0a0.'

So, can your wrapper be available under the above environments? Expect to see your reply.

Regards,
 
  bonlam 04:08  20.12.2012  
Thanks for this wonderful tool! But I ve got a problem when importing it to my own project.

I added the source code to my c++ project in xcode.
many errors before I link the "libsqlite3.dylib", after linking it, 8 errors remain there and I have no idea why.

I can see those functions in the "sqlite3.h" header provided by iPhone SDK 6.0, the sqlite version is 3.7.13.
And all of them are from KompexSQLiteStatement.

Any idea about it? I need it urgent! Many thanks!

"Undefined symbols for architecture i386:
"_sqlite3_column_database_name", referenced from:
Kompex::SQLiteStatement::GetColumnDatabaseName(int) const in KompexSQLiteStatement.o
Kompex::SQLiteStatement::GetColumnDatabaseName(std::string const&) const in KompexSQLiteStatement.o
"_sqlite3_column_database_name16", referenced from:
Kompex::SQLiteStatement::GetColumnDatabaseName16(int) const in KompexSQLiteStatement.o
Kompex::SQLiteStatement::GetColumnDatabaseName16(std::string const&) const in KompexSQLiteStatement.o
"_sqlite3_column_origin_name", referenced from:
Kompex::SQLiteStatement::GetColumnOriginName(int) const in KompexSQLiteStatement.o
Kompex::SQLiteStatement::GetColumnOriginName(std::string const&) const in KompexSQLiteStatement.o
"_sqlite3_column_origin_name16", referenced from:
Kompex::SQLiteStatement::GetColumnOriginName16(int) const in KompexSQLiteStatement.o
Kompex::SQLiteStatement::GetColumnOriginName16(std::string const&) const in KompexSQLiteStatement.o
"_sqlite3_column_table_name", referenced from:
Kompex::SQLiteStatement::GetColumnTableName(int) const in KompexSQLiteStatement.o
Kompex::SQLiteStatement::GetColumnTableName(std::string const&) const in KompexSQLiteStatement.o
"_sqlite3_column_table_name16", referenced from:
Kompex::SQLiteStatement::GetColumnTableName16(int) const in KompexSQLiteStatement.o
Kompex::SQLiteStatement::GetColumnTableName16(std::string const&) const in Ko


// Comment by Sven:
// If you downloaded the SQLite files by yourself or if you use SQLite files
// which were provided by your OS then please try to add the following defines
// on top of the file sqlite3.c:
// #define SQLITE_ENABLE_COLUMN_METADATA
// #define SQLITE_ENABLE_RTREE
// Afterwards you can try to compile it again.
 
  sataya 10:44  09.11.2012  
Hi,

Thanks for a wonderful wrapper. This is really simple and easy to use. I was wondering if is that possible to save the table data into a vector ? if it is can u guide me or give me some tips how do i do that ?

thx

// Comment by Sven:
// I've written you an e-mail.
 
  Alexander 12:16  09.08.2012  
Hello!

Thanks for the good piece of code.
I'm wondering if it is possible to use sqlite as a static lib with Kompex?

// Comment by Sven:
// Yes it is possible to use the Kompex SQLite wrapper as static lib.
// You can build the static lib with the provided NetBeans or Visual Studio project file.
 
  Frank again 08:16  30.05.2012  
Oh, I forgot in my make-your-wish-example:

Result res = stmt.Query();
std::for_each(begin(res), end(res), [&] (const Row& row) { /* use the data */ });
 
  Frank 08:13  30.05.2012  
What's with the Pointers and FreeXXX Functions?

This is no C++, this is C with classes.

Ever heared of RAII?

Why not simply:

Database db("MyFileName");
Statament stmt(db, "Select X from Y WHERE z = ?");
stmt.Bind(1, 42); // Operator-Overloading.
Result = stmt.Query();

Is there no good C++ Wrapper for SQLite?

// Comment by Sven:
// Thanks for the feedback. This is a good C++ SQLite Wrapper but it uses only
// another approach. If it doesn't fit your needs then feel free to use another wrapper.
 
  DJuego   |   E-Mail: DJuego@gmail.com 19:25  05.04.2012  
First.

I am a Spanish Dev. And I am very grateful for your 'Wrapper'. There are other SQLite wrappers, but Kompex is simple, elegant,beautiful. A calculated design.

A question. Why 'Kompex' name? (:-D
A suggestion: a forum for Kompex

Thanks!

DJuego


// Comment by Sven:
//
// Hi DJuego,
//
// Thank you for the praise. :D
//
// Actually, the "Kompex SQLite Wrapper" is a sub-project of the Kompex
// project (an online role playing game).
// First, the wrapper was developed for the internal usage in the Kompex project.
// But later I decided to make the wrapper public. So the name "Kompex" remained.
// But the word "Kompex" itself has no certain meaning.
//
// I believe a board would be a nice idea.
// Currently, the poor guestbook is abused as support platform. ^^
 
  vasvladal 06:42  04.04.2012  
Sir, your library works well, only in case of completion of my program there is the strong memory leaks.
The program is developed on the Visual Studio 2010.
Config:
*.h

class *
{
...
public:
static Kompex::SQLiteDatabase *pDatabase;
static Kompex::SQLiteStatement *pStmt;
...
};

*.cpp
1.)
Kompex::SQLiteDatabase* *::pDatabase = NULL;
Kompex::SQLiteStatement* *::pStmt = NULL;

2.)
BOOL *::OnInitDialog()
{
...
pDatabase = new Kompex::SQLiteDatabase(namefileOfBase, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, 0);
// move database to memory, so that we are work on the memory database hence
pDatabase->MoveDatabaseToMemory();
pStmt = new Kompex::SQLiteStatement(pDatabase);

pStmt->SqlStatement("CREATE TABLE Connections ( soc_kl INTEGER, SN VARCHAR(50), soc_vu INTEGER)");
...
}
3.)
In work function (many threads handler):
void *::workfunc(Str& c)
{
...
pStmt->Sql("INSERT INTO Connections( soc_kl, SN, soc_vu) VALUES(?, ?, ?);");
pStmt->BindInt(1, c.m_socket);
pStmt->BindString(2, c.string);
pStmt->BindInt(3, c.m_socket);
pStmt->Execute();
...
}

4.)
In destroy function (or destructor):
void destroy()
{
...
if (pDatabase)
{
// save the memory database to a file
// if you don't do it, all database changes will be lost after closing the memory database
pDatabase->SaveDatabaseFromMemoryToFile(namefileOfBase);
pDatabase->ReleaseMemory();
if (pStmt)
{
//pStmt->Reset();
//pStmt->FreeQuery();
delete pStmt;
pStmt = NULL;
}
//pDatabase->Close();
delete pDatabase;
pDatabase = NULL;
}
...
}

// Comment by Sven:
// I don't see any problem there. Are you sure that the memory leak comes from my
// library?!
 
  Jordan 22:21  14.03.2012  
Hi,

Great library, but there seem to be a few bugs and/or improvements that would be nice:

1) GetColumnString() fails if the SELECT returns a NULL value, because it's attempting to stream into a stringstream.
2) Is there a reason why we can't add multiple statements into one Sql() command? i.e. "Pragma foreign_keys="on"; CREATE TABLE...."
3) It would be nice to take advantage of the vmprintf capabilities of sqlite
4) GetNumberOfRows() returns the number of rows from which row you are on until the end, not the TOTAL number of rows in the SELECT. That seems dangerous. There should at least be some documentation about that.

Thanks!

// Comment by Sven:
// 1) Thanks for reporting this bug. I will return an empty string in the future.
// 2) As far as I know SQLite doesn't support that. Anyway, in my oppinion it is a
// little security feature to prevent a range of SQL injections (like in PHP).
// 3) I will take a look at it.
// 4) You are right. It is really necessary to improve the documentation for this
// function because the misuse could lead to infinite loops.
//
// Thanks for your feedback.

 
  Bruce Meier 14:15  06.03.2012  
Please help me use Kompex wrapper in Linux C++.

// Comment by Sven:
// I've written you an e-mail.
 
  somma 06:22  16.02.2012  
Hi!
I am really thank about your great job!!
I have a question about error.
I use prepared statement.

Kompex::SQLiteStatement::Sql()
-> Kompex::SQLiteStatement::BindXXX()
-> Kompex::SQLiteStatement::Execute()
-> Kompex::SQLiteStatement::Reset()

after work, When I tyring to close database "unable to close due to unfinalized statements" exception occurred.

Do you have any idea why?
thanks.

ps. I think my problem is same below question.
Kompex::SQLiteStatement::FreeQuery()
-> Kompex::SQLiteDatabase::Close() <<==!!!
Kompex::SQLiteStatement::Sql()


// Comment by Sven:
// The error message "unable to close due to unfinalized statements"
// occurs only when you forget to call FreeQuery() after you executed
// the prepared statement.
 
  WOW   |   E-Mail: ilovethis@love.com 19:49  04.02.2012  
This is great!!
 
  Howard 09:01  20.01.2012  
Hi!
It s great SQLite wrapper.
I'd appreciate what you've done.
great job.

And I have a question, and hope you can give the suggestion.

When I try to get value from invalid column name . there's will be a exception. and the exception CAN be catch by the catch(SQLiteException &ex).
But after that, I use pStmt->FreeQuery();
And after that, I use pDatabase->Close();
There will be a exception "unable to close due to unfinalised statements". And VS10 throw a exception. And break my program.

This only happen when I try to get value from a invalid column name.


Do you have any idea why?

Thanks.

Howard

// Comment by Sven:
// I've written you an e-mail and explained the issue.
 
  Mike 20:07  21.11.2011  
Hi!
Love you code, thanks again! Is there a way to use Kompex to connect to an existing SQLite file that was created with C# SQLite with a connection string specifying a password?

// Comment by Sven:
// As far as I know, SQLite doesn't support any possibility to protect or open a
// database with a password. Therefore, I think the answer is no. I assume that
// C# (.NET) implemented an own protection.
 
  Klaus 11:45  14.11.2011  
Hello,

I downloaded the tar.gz and compiled it by simple running the Makefile in the folder Kompex SQLite Wrapper in a Linux console. It works fine but only builds the debug library in lib/debug. Is there a way to build the release version from console?

// Comment by Sven:
// I've written you an e-mail.
 
  shar 07:33  21.09.2011  
hello

// Comment by Sven:
// Hello. :D
 
  TheLostMind   |   E-Mail: thelostmind@hotmail.com 10:08  19.09.2011  
Sven,
Thank you very much to e-mail me,but I'm so sorry, I never received your email.
I guess the problem is the ProcessDDLRow callback function cannot processor the unicode string . Sqlite original function can afford Unicode support in memory-database,I wish you add Unicode support or next time I modify your wrapper and add it myself.
 
  mkhan 11:18  13.09.2011  
i need now how to use with MFC , i am new in DataBase SQLite

PLZ Help

// Comment by Sven:
// This request is too vague. I can't provide a tutorial for such basic stuff. Sorry.
// If you should have a specific problem I will help you.
 
  Daeran 19:26  02.09.2011  
Hello! I found this wrapper a while ago, and it seemed interesting to me.
However, after having downloaded it, I can't compile it at all. I'm using Visual Studio 2010 and I'm getting this error when trying to compile the project:

"Unable to start program

'.../KompexSQLiteWrapper_Static_d.lib'"

I hope you can help me with this =)


// Comment by Sven:
//
// Please compile the solution as follows:
// Build -> Batch Build -> tick all projects -> Rebuild
//
// After that, you should have all static and dynmaic libraries and the example application.
//
// Furthermore, it is not possible to debug the "Kompex SQLite Wrapper" project because
// it is an library. If you want to debug the example application project
// "Kompex SQLite Example" then ensure that this project is set as "StartUp Project"
// (right click on the project and click on "Set as StartUp Project").
 
  TheLostmind 14:36  25.08.2011  
///////////

std::wstring m_Wstring = m_strFileName.GetBuffer(m_strFileName.GetLength());
m_strFileName.ReleaseBuffer();
CTransTxt::unicodeToUTF8(m_Wstring,MemFileName);
// pSqlDataBase = new Kompex::SQLiteDatabase;
// pSqlDataBase->Open(MemFileName,SQLITE_OPEN_READWRITE,NULL);

pSqlDataBase = new Kompex::SQLiteDatabase(MemFileName,SQLITE_OPEN_READWRITE,0);
if (pSqlDataBase == NULL)
{
return false;
}
pSqlDataBase->MoveDatabaseToMemory();
///////
Hi, my project is unicode (UTF-16),and I translation the file name to UTF-8 format ,but when I do : pSqlDataBase->MoveDatabaseToMemory(); ,exception orcured :

int SQLiteDatabase::ProcessDDLRow(void *db, int columnsCount, char **values, char **columns)
{
if(columnsCount != 1)
{
KOMPEX_EXCEPT("error occured during DDL: columnsCount != 1");
return -1;
}

// execute a sql statement in values[0] in the database db.
if(sqlite3_exec(static_cast<sqlite3*>(db), values[0], 0, 0, 0) != SQLITE_OK)
KOMPEX_EXCEPT("error occured during DDL: sqlite3_exec");
=====================
KOMPEX_EXCEPT("error occured during DDL: sqlite3_exec"); //what's wrong ,I can't find where the problem is


// Comment by Sven:
// I've written you an e-mail.
 
  Jean-Pierre Laroche 22:45  17.08.2011  
hello,
my english hum....
google is my friend lol
First thank you for your work
actually it works in utf-16 with the parameters indicated
Now I attack my problem TUI

I worked with an old trick that is in code project, but wrap it with your top
I compare a wxsqlite3 for me but with more freedom.

thank you

@bientôt english ( à bientôt goodbye and good friendly)

you should put lapossibilité to donate


// Comment by Sven:
// You're welcome.
//
// Unfortunately, I mustn't provide the possibility to donate.
// In Germany it is necessary to register a company in order to receive donations
// for freeware because you must pay taxes for received donations. Therefore, it
// isn't possible to provide an official possibility..
 
  Jean-Pierre Laroche 19:53  06.08.2011  
bonjour,
je travail avec Ubuntu
ça fonctionne bien dans l'ensemble
la lib est facile à faire avec codeblock
l'exemple est clean
sauf:
impossible de ce servir de UTF16 linux !!!

ps( pas trop grave pour moi mais je travaille sur un projet qui récupère les sources ISERIE AS400 sur WIN7 puis relit le tout sur linux pour faire un TUI(ncurses) 5250 donc j'utilise votre wrapper sur win7 et linux)
merci beaucoup


// Comment by Sven:
// Hmm.. I can't speak/write French.. used a online translator now..
// If I understood your concern correctly then it isn't possible for you to use
// UTF16 with Linux. Please try to set the compiler flag "-fshort-wchar" and
// compile your project again.
 
  Dmitry Samal 09:52  05.08.2011  
Hi, again.
Another remark - I guess it may be useful. In case of obtaining errors like this one (under VS 2008):
Linking...
1>KompexSQLiteStatement.obj : error LNK2019: unresolved external symbol _sqlite3_column_database_name referenced in function "public: char const * __thiscall Kompex::SQLiteStatement::GetColumnDatabaseName(int)const " (?GetColumnDatabaseName@SQLiteStatement@Kompex@@QBEPBDH@Z)

The problem is solving by adding the string «#define SQLITE_ENABLE_COLUMN_METADATA» to sqlite3.h file. Generaly, it’s old problem of SQLite but not Kompex. You can find some reports about this in google.


// Comment by Sven:
// SQLITE_ENABLE_COLUMN_METADATA is already defined in the sqlite3.c file which is
// delivered with the Kompex SQLite Wrapper. Therefore, that error cannot occur.
// You will get this error message only if you exchange the sqlite3 files with
// another sqlite3 version. Then it will be necessary to add that define again.
 
  Dmitry Samal 11:34  03.08.2011  
Hello,
Thank you for your code.
Just a remark - you forgot to add KompexSQLiteBlob.h and .cpp files to the last version of the project under VS2008. (Maybe under VS2010 too - I didn't check).

// Comment by Sven:
// Thank you for the advice.
// I've corrected the project file now and uploaded it again.
// The VS2010 project file was all right. ; )
 
  benjamin 05:51  29.07.2011  
Thanks for your altruistic contribution.

There is a problem that confuse me about using "MoveDatabaseToMemory".
1,when I move the general database to the memory and then using "SaveDatabaseFromMemoryToFile" to save the database. After that, using "delete pDatabase", it's all doing well.
2,when I move the database which contains some FTS3 virtual tables to the memory and then using "SaveDatabaseFromMemoryToFile" to save the database. It's working well, but then when i finally "delete pDatabase", it's crashed at "Kompex::SQLiteDatabase::Close()" function.

My question is does "move to memory" behavior work well with FTS3 virtual table ?

ps: the call stack about the crash.
--------------------------------------
sqlite3_finalize(sqlite3_stmt * pStmt=0x01cd4c68)
fts3DisconnectMethod(sqlite3_vtab * pVtab=0x01b88168)
sqlite3VtabUnlock(VTable * pVTab=0x01a65a00)
sqlite3VtabUnlockList(sqlite3 * db=0x01a5acd8)
sqlite3ResetInternalSchema(sqlite3 * db=0x01a5acd8, int iDb=-1)
detachFunc(sqlite3_context * context=0x0012ef08, int NotUsed=1, Mem * * argv=0x01c8ad08)
sqlite3VdbeExec(Vdbe * p=0x01b22360)
sqlite3Step(Vdbe * p=0x01b22360)
sqlite3_step(sqlite3_stmt * pStmt=0x01b22360)
sqlite3_exec(sqlite3 * db=0x01a5acd8, const char * zSql=0x00edc7c8, ...)
Kompex::SQLiteDatabase::Close()


// Comment by Sven:
// Till this day, I didn't use the FTS3/FTS4 feature. Therefore I'm not sure
// why your program crashs. I've written you an e-mail to track down that crash.
//
// Result: FTS3/FTS4 can be used with Kompex SQLite Wrapper.
// The above error occured because of the usage of an older version
// of Kompex SQLite Wrapper.
 
  Mike Gagnon 15:01  23.06.2011  
Thanks for your code - I love it! I'm just wondering though, how would I do a blob insert?

In your example code you have the following, but it's text:
pStmt->SqlStatement("CREATE TABLE IF NOT EXISTS boarduser (userID INTEGER NOT NULL PRIMARY KEY, username VARCHAR(20), picture BLOB)");
pStmt->SqlStatement("INSERT INTO boarduser (userID, username, picture) VALUES (1, 'apori', 'abcdefghijklmnopqrstuvwxyz')");

That last column with the alphabet is what I would like to replace with, say, a vector of 1000 floats. Possible?


// Comment by Sven:
// You're welcome. :)
//
// I used this abc string as example because a binary file is nothing else than a text
// with some special characters (byte values).
//
// You have two possiblities to insert a blob, depending on your current source code:
// 1. replace the abc string with your own std::string, char*, std::wstring or wchar_t*
// variable in the SqlStatement() method
// 2. use a prepared statement and afterwards the BindBlob() method - then you can
// insert everything you want with the void* (you can find a little prepared statement
// example in the example application from line 55 to 63)
//
// In the case that something isn't clear you can write me an e-mail and will try to give
// you further information.
 
  kylinxh 05:22  23.06.2011  
thanks for your nick work!

is it the class with Unicode support?

// Comment by Sven:
// Yes. Every method which works with strings exists also with wchar_t* parameter
// and wchar_t* return value.
 
  Hyeokju 09:57  07.04.2011  
Hello,

I want use your code, but I can't find how to install it, in particular on Linux. Could you help me?

// Comment by Sven:
// I've written you an e-mail. ; )
 
  DracoDynasty 11:52  23.03.2011  
Hello,

Is there a way to insert/get booleans ? I didn't see any BindBool/GetBool method.

// Comment by Sven:
// The following sentence is written on the sqlite website: "SQLite does not have a
// separate Boolean storage class. Instead, Boolean values are stored as integers
// 0 (false) and 1 (true)." Therfore I didn't implement such a function because you
// can use the integer functions. Maybe it would be usefull if I would provide bool
// funtions which do the int<->bool convert work internally?!
 
  DinhBN 06:37  21.03.2011  
You can add encrypt/decrypt to class? (wxsqlite3 has this feauture)?

// Comment by Sven:
// An interessting feature which would be really usefull. I would need this feature too ; ).
// But I have furthermore no time to implement it - work and study at the same
// time need too much time *sigh*
 
  DinhBN 02:41  26.02.2011  
you can write some example "update" statement sql

// Comment by Sven:
// I've added a detailed example for UPDATE statements under the menu item
// "Examples". It will be also available in the sample application of the next
// Kompex SQLite Wrapper release.
 
  HoKun, Chung   |   E-Mail: heaven2@paran.com 12:52  23.02.2011  
Hi..
I try to use Kompex SQLite Wrapper.
I Download the wrapper class, example class.
But, I Builded,execute, I met the error message.
"The specified file is an unrecognized ....
KompexSQLiteWrapper_static.lib"
4 Mode(Debug, DebugDynamic, Release, ReleaseDyanamic..) also same.
What can i do next ?
Thanks..

// Comment by Sven:
// I've written you an e-mail. ; )
 
  fh   |   E-Mail: aaa945260@sohu.com 17:10  21.02.2011  
how to use sqlite3_blob_read() sqlite3_blob_write()??()()
with a big blob(>1G) incrementally; can be realized by such as functiong writeblob(filepath)
readblob(savepath) ?

// Comment by Sven:
// As discussed over email I will take a look into that topic.
 
  DinhBN 18:51  20.02.2011  
Add function compress database to class SQLiteDatabase

// Comment by Sven:
// It would be a great feature but it isn't provided directly by SQLite.
// I think in this case it should be developed as an extension.
// Unfortunately, I haven't enough time to develop it..
 
  Gohy Leandre 04:50  10.02.2011  
Works fine on Mac OS X (10.6.6).

But some changes was needed
CCC=g++-4.4
CXX=g++-4.4

to

CCC=g++
CXX=g++

in .mk files

and replace .so file extension to .dylib in .mk files

UNAME := $(shell uname)
ifeq ($(UNAME),Darwin)
# fill me :p
endif

// Comment by Sven:
// Cool. I think this will help other people. : )
 
  gelin yan 06:55  03.08.2010  
hi...I am interested in this wrapper. I have a question about concurrency usage.

Does this wrapper work properly in multiple thread environment? I mean it is quite often to open the same db simultaneously.I have no idea whether you have a lock for that.

// Comment by Sven:
// I never tried it in a multiple thread environment.
// Therefore I can't give you a concrete answer. Sorry.
// But I think that I will test it one day if I have a lot of time.
 
  faezeh sadat 11:18  25.07.2010  
hi,i need C-Wrapper for connecting and using SQLITE & MYSQL databases,and i need to know the process of using them in a c-program on ubuntu OS,please help me?

// Comment by Sven:
// The Kompex SQLite wrapper is only for C++ and SQLite.
// If you need a C-API you could use the API from the SQLite developers.
// Maybe you can find an API which combines the SQLite and MySQL C-API.
 
  BronzeBeard 06:24  13.06.2010  
Disreguard what i wrote below, it still doesn't work for me...

Is there anyway to get a import lib, along with a dll?

// Comment by Sven:
// I've written you an e-mail.
 
  BronzeBeard 05:46  13.06.2010  
Hello sir,

I noticed that in vs2005 your project was not outputting a import library for your dll file...
This may be a bug, this is what I changed to fix it


#if _WIN32
# define _CDECL _cdecl
# if defined(_KOMPEX_SQLITEWRAPPER_EXPORT) && defined(_KOMPEX_SQLITEWRAPPER_DYN)
# define _SQLiteWrapperExport __declspec(dllexport)
# elif defined(_KOMPEX_SQLITEWRAPPER_DYN)
# define _SQLiteWrapperExport __declspec(dllimport)
# else
# define _SQLiteWrapperExport
# endif
#else
# define _SQLiteWrapperExport
#endif

#endif
#if _WIN32
# define _CDECL _cdecl
# if defined(_KOMPEX_SQLITEWRAPPER_EXPORT) && defined(_KOMPEX_SQLITEWRAPPER_DYN)
# define _SQLiteWrapperExport __declspec(dllexport)
# elif defined(_KOMPEX_SQLITEWRAPPER_DYN)
# define _SQLiteWrapperExport __declspec(dllimport)
# else
# define _SQLiteWrapperExport __declspec(dllimport)
# endif
#else
# define _SQLiteWrapperExport
#endif

#endif


to


#if _WIN32
# define _CDECL _cdecl
# if defined(_KOMPEX_SQLITEWRAPPER_EXPORT) && defined(_KOMPEX_SQLITEWRAPPER_DYN)
# define _SQLiteWrapperExport __declspec(dllexport)
# elif defined(_KOMPEX_SQLITEWRAPPER_DYN)
# define _SQLiteWrapperExport __declspec(dllimport)
# else
# define _SQLiteWrapperExport __declspec(dllimport)
# endif
#else
# define _SQLiteWrapperExport
#endif

#endif
 
  Barbara 16:10  08.06.2010  
Hello,

Your code seems to be very useful for me, but I don't see any document explaining how to install it, in particular on Linux.

Could you please tell me what the required installs are (SQLite, ...) and how I could make your code work on Linux ?

Thank you in advance.

Cheers,

Barbara

// Comment by Sven:
// I've written you an e-mail.
 
  Sven Broeske   |   E-Mail: SvenBroeske@web.de 20:05  20.05.2010  
The guestbook is open now.
Feel free to leave a comment. : )