SQLite Windows Class

User projects written in or related to FreeBASIC.
Post Reply
rpkelly
Posts: 52
Joined: Sep 03, 2016 22:36

SQLite Windows Class

Post by rpkelly »

Sharing the SQLite class I use for WIndows. Tested with 100 threads pulling 46K rows each on bit 32 and 64 bit compiles using the default 1MB stack.

https://github.com/breacsealgaire/FreeB ... Lite-Class

Added SQLite connection pool class and example. Useful for multi threaded access.
Last edited by rpkelly on May 14, 2017 16:38, edited 2 times in total.
Tourist Trap
Posts: 2958
Joined: Jun 02, 2015 16:24

Re: SQLite Windows Class

Post by Tourist Trap »

Hi rpkelly, thanks for this. Have you a small example to get started with your lib?
rpkelly
Posts: 52
Joined: Sep 03, 2016 22:36

Re: SQLite Windows Class

Post by rpkelly »

Tourist Trap wrote:Hi rpkelly, thanks for this. Have you a small example to get started with your lib?
There is a sample script cCTSSQLite_Script_txt on Git. One thing to be aware of is that the library was designed to support both a standalone client and a client server design. The spooler class when returning the results provides a file handle with the file pointer at the beginning and the file size so a server can begin to read and send via TCP. For a standalone client, one additional spooler call to function EndSpoolStreamFile that sets the file pointer to the first result block is needed and shown in the sample test script.
rpkelly
Posts: 52
Joined: Sep 03, 2016 22:36

Re: SQLite Windows Class

Post by rpkelly »

Added Windows crypto class useful for SQLite client/server authentication with example of one way to design a handshake.
rpkelly
Posts: 52
Joined: Sep 03, 2016 22:36

Re: SQLite Windows Class

Post by rpkelly »

This SQLite Windows collection is the beginning of a complete set of classes for a client/server group. Over the next several months, there are basically three additional classes. Socket (already in place with preliminary testing), Client, and, Server classes after which all the tools will be in place. The developer will build the GUI part of the server and use a message only window for communication with the server class which will provide the supporting functions for handshake, SQLite database and sending the results. The server class will be designed around one TCP listening port and one UDP listening port. The UDP port is used as a server discovery.
rpkelly
Posts: 52
Joined: Sep 03, 2016 22:36

Re: SQLite Windows Class

Post by rpkelly »

Added a thread pool class that the server class will eventually use.

https://github.com/breacsealgaire/FreeB ... Lite-Class
OakLeaf
Posts: 5
Joined: Nov 30, 2012 19:30

Re: SQLite Windows Class

Post by OakLeaf »

Wow, this is Great! One of the most useful projects to appear on FB. I'll definitely be using this. Thanks so much.
PeterHu
Posts: 146
Joined: Jul 24, 2022 4:57

Re: SQLite Windows Class

Post by PeterHu »

rpkelly wrote: May 27, 2017 0:14 Added a thread pool class that the server class will eventually use.

https://github.com/breacsealgaire/FreeB ... Lite-Class
Greetings!

I am trying to learn this class wrapper and managed to get the script text file(renamed to *.bas) compiled and ran,except the cCTSQLite_Script one regarding the Clear function in cCTSQLLiteCrypto.bi:

Code: Select all

   Private Function cCTSQLLiteCrypto.DecryptText (ByRef sCipherText as String, _
                                               ByRef sPlainText as String, _
                                               ByVal iEncryptIndex1 as Long, _
                                               ByVal iEncryptIndex2 as Long) as BOOLEAN

     Dim lStatus           as BOOLEAN
     Dim  Key              as BCRYPT_KEY_HANDLE
     Dim sIV               as String
     Dim sKey              as String
     Dim sKeyHash          as String

    ''''..........................

    Clear(StrPtr(sKey),Len(sKey),0)
    Clear(StrPtr(sIV),Len(sIV),0)

Compiler error message:

Code: Select all

E:\Learning\FreeBasic\code\FreeBasic-32-64-Windows-SQLite-Class-master\cCTSQL\cCTSQLLiteCrypto.bi(205) error 181: Invalid assignment/conversion, at parameter 1 of CLEAR() in 'Clear(StrPtr(sKey),Len(sKey),0)'
E:\Learning\FreeBasic\code\FreeBasic-32-64-Windows-SQLite-Class-master\cCTSQL\cCTSQLLiteCrypto.bi(206) error 181: Invalid assignment/conversion, at parameter 1 of CLEAR() in 'Clear(StrPtr(sIV),Len(sIV),0)'

Learning from FB Manual:

Code: Select all

Clear
Clears or initializes some memory

Syntax
Declare Sub Clear cdecl ( ByRef dst As Any, ByVal value As Long = 0, ByVal bytes As UInteger )

Usage
Clear( dst, [value], bytes )


Parameters
dst
starting address of some memory

value
the value to set all bytes equal to 

bytes 
number of bytes to clear


So I tried to change Clear(...) to

Code: Select all

    Clear(StrPtr(sKey),0,Len(sKey))
    Clear(StrPtr(sIV),0,Len(sIV))
But it won't help,same error message.

BTW, in cctSqlite.bi I find this:

Code: Select all

#Include Once "windows.bi"
So does this mean this class wrapper is for Windows only?

Any help on this would be appreciated.
SARG
Posts: 1755
Joined: May 27, 2005 7:15
Location: FRANCE

Re: SQLite Windows Class

Post by SARG »

Try with clear (*strptr(skey).....

If windows.bi is used it should be only for Windows.
PeterHu
Posts: 146
Joined: Jul 24, 2022 4:57

Re: SQLite Windows Class

Post by PeterHu »

SARG wrote: Mar 31, 2023 11:26 Try with clear (*strptr(skey).....

If windows.bi is used it should be only for Windows.
It compiles now.Thank you!

Yes,it is only for Windows since using windows API for encryption.
Post Reply