Page 2 of 9

Posted: Tue May 15, 2007 8:13 pm
by rsts
This looks great.

I had been wanting to use prototypes but needed blob ( ie prepare, step finalize) support for my applications.

Today's additions should fill the bill.

Many thanks for your contributions.

cheers

Posted: Wed May 16, 2007 1:50 pm
by bembulak
I'm sooo late.

This looks great - I think it's pretty cool that your sources are crossplattform!

Thanks!

Posted: Sun May 27, 2007 12:32 am
by ts-soft
Small Bugfix in both versions, thx to kiffi for bugreport

Posted: Mon May 28, 2007 5:30 am
by rsts
I really apreciate all the effort that has gone into putting this together.

I do have a question regarding converting to use this.

I have a rather involved program using sqlite3 somewhat extensively, based on Kiffi's fine wrapper. In looking to convert it to this code, I find it to be a little more involved than just replacing the function names. Parameters have been switched in the procedures, callback's added, etc.). Net is it will involve some work, and based on my history, then some re-work :).

My question is, what are the benefits to the prototype approach over the previous approach. When I start looking at the database access itself, I don't really see any appreciable differences, but I may well be missing something.

In the opinion of the 'experts' are their benefits sufficient to make it worth my while converting, and if so, how might I understand what they are?

Sorry for the 'newbie'ish question, but I still have a lot to learn about both sqlite and PureBasic.

Thanks for your time.

cheers

Posted: Mon May 28, 2007 5:43 am
by ts-soft
This Version is a bit easier then PBOSL_SQLite3, i hope, only real usefull
functions implemented.
This Version have full Unicode-Support (UTF-8 in Ansi- or Unicode-Mode)
Full Support for Linux, MacOS and Windows.

Kiffi himself uses my version :wink:

Posted: Mon May 28, 2007 6:27 am
by rsts
Thanks for your quick response. You must never sleep, or you're a 'team' of people :) - And I'm in no way attempting to criticise or belittle your fine work.

I have no reservations about using this code and will do so in future sqlite based projects. My qustion is really regarding any benefit to be achieved in converting an existing program which uses Kiffi's wrapper to utilize this instead. Would there be any 'benefits' I would see in that program, besides access to unicode and a few more functions? Is this code in any way more 'robust' than kiffi's. That is - is "If SQ3\exec" in some way 'better' than "hResult = CallCFunctionFast(sqlite3_exec, lDataBaseHandle, sSQLQuery, #Null, #Null, @ReturnValue)"? And if it is, could someone explain how?

Just wanting to understand if it's worth the effort of converting an existing large program, or if should just wait for the next project :)

cheers

Posted: Mon May 28, 2007 6:45 am
by ts-soft
rsts wrote:That is - is "If SQ3\exec" in some way 'better' than "hResult = CallCFunctionFast(sqlite3_exec, lDataBaseHandle, sSQLQuery, #Null, #Null, @ReturnValue)"? And if it is, could someone explain how?

Code: Select all

Procedure.l SQLiteExecute(hDB.l, Statement.s, callback.l = 0)
  If SQ3\exec ; check only if functionpointer
    If Not SQ3\exec(hDB, Statement, callback); give only on #SQLite_OK a #true, errormessage is stored in errmsg, is not required to check here
      ProcedureReturn #True
    EndIf
  EndIf
  ProcedureReturn #False
EndProcedure
see comments, and it's shorter than kiffis errorhandling

Code: Select all

CallCFunctionFast
You should ever use prototypes in PB4, is more sure :wink:

Posted: Mon May 28, 2007 3:11 pm
by rsts
Thanks again for your response.

Might there be any explanation of the return values of true or false for sqlitestep? In looking at the code I can't determine how it's determining an appropriate return. Is it checking for #SQLITE3_OK and returning true/false based on that? If so, how might I determine when either #SQLITE3_ROW or #SQLITE3_DONE are returned versus some other return code?

cheers

Posted: Mon May 28, 2007 7:11 pm
by ts-soft
All results like PB, <> 0 is good!
If a value 0, so you have to check this with for example: SQLiteErrorMsg(hDB.l)

SQLiteErrorCode(hDB) give you the normal errorcode, in errorcode is 0 the best :wink:

Posted: Tue May 29, 2007 7:39 pm
by michel
Hello,

I recently switched from the former PBOSL-libraries to yours but I have problems with the "german Umlauts". My dbase is encoded in UTF8 and without the compiler unicode switch set, I see no longer any "Umlaut". Can you give me a tip what I could do?

michel

Posted: Tue May 29, 2007 8:18 pm
by Kiffi
Hello michel,
michel wrote:Can you give me a tip what I could do?
the latest Version is 'umlaut-fixed'. See the first posting. ;-)

Greetings ... Kiffi

Posted: Tue May 29, 2007 9:55 pm
by ts-soft

Posted: Wed May 30, 2007 9:06 am
by michel
I just discovered that my db is encoded in codepage 1252 (Ansi latin I). How can I transform data to UTF-8?

Posted: Thu May 31, 2007 1:31 am
by ts-soft
Update, both Version!

SQLiteExecute(), added optional para for callback

SQLiteOpen(), added flag for ASCII(Ansi) Mode
This works only in ASCII-Mode and is only to convert your old db's
In Unicode-Mode this flag is ignored!

The ASCII-Flag have global affect, please use it only in this form:

Code: Select all

If SQLiteInit()
  hDB = SQLiteOpen("MyDB", #True)
  ; reading
  SQLiteClose(hDB.l)
  hDB = SQLiteOpen("MyDB", #False)
  ;writing
  SQLiteClose(hDB.l)

EndIf

More examples

Posted: Thu May 31, 2007 6:18 am
by Fangbeast
Thomas, I can't see how to use blobs in a complex table from the example, feeling pretty dumb at the moment.

Could you combine your example that stores 5 records with your example that stores blobs so there are blobs in every record and show how to select a specific record including the blob for that record?

Sorry to bother you.