Page 1 of 1

Opensource SQL Database Lib with Blobs and Management Studio

Posted: Sat Jul 11, 2009 10:22 am
by RocketRider
Hello,

I have writen a SQL Database Library, with this lib you can use Blobs in your SQLite Database. The Blobs can be encrypted or compressed.
This Lib don't need any external Files like dlls.
I have also writen a managent studio for this Library.
The Complete Library is Opensource under Zlib-Licence.
Image

Screenshots:
http://www.rocketrider.eu/ScreenShots/D ... udio_1.jpg
http://www.rocketrider.eu/ScreenShots/D ... udio_3.jpg
http://www.rocketrider.eu/ScreenShots/D ... udio_4.jpg

Documentation:
DB_Create(sFile.s, bCompressed = #True)
Creates a new database file. The file is compressed by windows (note the file size is limited to 30 GB in this case) by default.
The function returns true for success.


DB_Open(sFile.s)
Opens an already existing database file.
The function returns true for success.


DB_Close(*Database.DATABASE)
Closes the database.
The function returns true for success.


DB_Update(*Database.DATABASE, sStatement.s)
Executes a statement, like DB_UpdateSync() but all calls to DB_Update() are in one transaction. So the command is much faster as DB_UpdateSync().
The transaction is commited if DB_UpdateSync(). DB_Query(), DB_Close() or DB_Flush() is called.
The function returns true for success.


DB_UpdateSync(*Database.DATABASE, sStatement.s)
Executes a statement.
The function returns true for success.


DB_Query(*Database.DATABASE, sStatement.s)
Begins a query. DB_EndQuery() must be called to end the query.
Important: You cannot use DB_Store... commands and DB_GetAs... commands in the same DB_Query()... DB_EndQuery() block.
The function returns true for success.


DB_EndQuery(*Database.DATABASE)
Ends a query started with DB_Query().
The function returns true for success.


DB_SelectRow(*Database.DATABASE, iRow.i)
Selects a row. The command is neccessary for DB_GetAsString(), DB_GetAsLong(), DB_GetAsQuad(), DB_GetAsDouble(), DB_GetAsBlobPointer(), DB_GetAsBlobSize(), DB_GetAsBlobFlags(), GetNumColumns(), DB_GetColumnTypeAsString() and DB_GetColumnName().
For the first row the parameter iRow must be 0.
Note: DB_SelectRow() must be called in a DB_Query()...DB_EndQuery() block.
The function returns true for success.


DB_GetAsString(*Database.DATABASE, iColumn.i)
Returns the value of the column as string. For the first column the parameter iColumn must be 0.
Note: DB_SelectRow() must be called before this command.
Important: You cannot use DB_Store... commands and DB_GetAs... commands in the same DB_Query()... DB_EndQuery() block.


DB_GetAsLong(*Database.DATABASE, iColumn.i)
Returns the value of the column as long (32-bit integer). For the first column the parameter iColumn must be 0.
Note: DB_SelectRow() must be called before this command.
Important: You cannot use DB_Store... commands and DB_GetAs... commands in the same DB_Query()... DB_EndQuery() block.


DB_GetAsQuad(*Database.DATABASE, iColumn.i)
Returns the value of the column as quad (64-bit integer). For the first column the parameter iColumn must be 0.
Note: DB_SelectRow() must be called before this command.
Important: You cannot use DB_Store... commands and DB_GetAs... commands in the same DB_Query()... DB_EndQuery() block.


DB_GetAsDouble(*Database.DATABASE, iColumn.i)
Returns the value of the column as double. For the first column the parameter iColumn must be 0.
Note: DB_SelectRow() must be called before this command.
Important: You cannot use DB_Store... commands and DB_GetAs... commands in the same DB_Query()... DB_EndQuery() block.


DB_GetAsBlobPointer(*Database.DATABASE, iColumn.i)
Returns a pointer to the blob. FreeMemory() must be called after the memory is not needed anymore. For the first column the parameter iColumn must be 0.
Note: DB_SelectRow() must be called before this command.
Important: You cannot use DB_Store... commands and DB_GetAs... commands in the same DB_Query()... DB_EndQuery() block.


DB_GetAsBlobSize(*Database.DATABASE, iColumn.i)
Returns the size of a blob in bytes. For the first column the parameter iColumn must be 0. It is faster to use MemorySize() instead of this function.
Note: DB_SelectRow() must be called before this command.
Important: You cannot use DB_Store... commands and DB_GetAs... commands in the same DB_Query()... DB_EndQuery() block.


DB_GetAsBlobFlags(*Database.DATABASE, iColumn.i)
Returns the flags of a blob. For the first column the parameter iColumn must be 0.
Note: DB_SelectRow() must be called before this command.
Important: You cannot use DB_Store... commands and DB_GetAs... commands in the same DB_Query()... DB_EndQuery() block.


DB_GetNumColumns(*Database.DATABASE)
Returns the number of the column. DB_SelectRow() must be called before this command.


DB_GetColumnTypeAsString(*Database.DATABASE, iColumn.i)
Returns the type of the column as string. For the first column the parameter iColumn must be 0. DB_SelectRow() must be called before this command.


DB_GetColumnName(*Database.DATABASE, iColumn.i)
Returns the name of the column as string. For the first column the parameter iColumn must be 0. DB_SelectRow() must be called before this command.


DB_StoreRow(*Database.DATABASE)
Stores a row in the database. This is neccessary aafter setting the values of a row with DB_StoreAsLong(), DB_StoreAsQuad(), DB_StoreAsDouble(), DB_StoreAsString() and DB_StoreAsBlob().
Important: You cannot use DB_Store... commands and DB_GetAs... commands in the same DB_Query()... DB_EndQuery() block.
The function returns true for success.


DB_StoreAsLong(*Database.DATABASE, iColumn.i, lValue.l)
Stores an integer as long (32-bit). For the first column the parameter iColumn must be 0.
Note: After setting all values of a row, DB_StoreRow() must be called to store it in the database
Important: You cannot use DB_Store... commands and DB_GetAs... commands in the same DB_Query()... DB_EndQuery() block.
The function returns true for success.


DB_StoreAsQuad(*Database.DATABASE, iColumn.i, qValue.q)
Stores an integer as quad (64-bit). For the first column the parameter iColumn must be 0.
Note: After setting all values of a row, DB_StoreRow() must be called to store it in the database
Important: You cannot use DB_Store... commands and DB_GetAs... commands in the same DB_Query()... DB_EndQuery() block.
The function returns true for success.


DB_StoreAsDouble(*Database.DATABASE, iColumn.i, dValue.d)
Stores a float point value as double. For the first column the parameter iColumn must be 0.
Note: After setting all values of a row, DB_StoreRow() must be called to store it in the database
Important: You cannot use DB_Store... commands and DB_GetAs... commands in the same DB_Query()... DB_EndQuery() block.
The function returns true for success.


DB_StoreAsString(*Database.DATABASE, iColumn.i, sText.s)
Stores a string. For the first column the parameter iColumn must be 0.
Note: After setting all values of a row, DB_StoreRow() must be called to store it in the database
Important: You cannot use DB_Store... commands and DB_GetAs... commands in the same DB_Query()... DB_EndQuery() block.
The function returns true for success.


DB_StoreAsBlob(*Database.DATABASE, iColumn.i, *Pointer.i, iSize.i, iFlags.i = #DB_BLOB_DEFAULT)
Stores a blob. For the first column the parameter iColumn must be 0. The parameter iFlags can be any combination of #DB_BLOB_COMPRESSED and DB_BLOB_ENCRYPTED Or just #DB_BLOB_DEFAULT for no compression And encryption.
Please note if a blob is compressed and encrypted and later decrypted with the wrong key, the application will probably crash, as there is no check whether decrypted data is correct.
Note: After setting all values of a row, DB_StoreRow() must be called to store it in the database
Important: You cannot use DB_Store... commands and DB_GetAs... commands in the same DB_Query()... DB_EndQuery() block.
The function returns true for success.


DB_GetLastErrorString()
Returns an error string for the last executed command.


DB_ShowQuery(*Database.DATABASE, sStatement.s, iWidth.i = -1, iHeight = -1, sTitle.s = "")
shows the result of the query in a window.
The function returns true for success.


DB_SetCryptionKey(*Database.DATABASE, sKey.s)
Sets the key to decrypt/encrypt blobs
The function returns true for success.


DB_SetCompressionLevel(*Database.DATABASE, iCompressionLevel.i = 9)
Sets the compression level for compressed blobs. The value can be between 0 and 9
The function returns true for success.


DB_Flush(*Database.DATABASE)
Makes sure that all changes are committed, if DB_Update() is used.
The function returns true for success.


DB_GetSQLiteVersion()
Returns the SQlite verion as string.





Licence:
Copyright (c) 2009 RocketRider

This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.

Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
This notice may not be removed or altered from any source distribution.

Download:
http://www.rocketrider.eu/Files/SQL-Man ... Studio.zip

Posted: Wed Jul 15, 2009 2:10 pm
by HAnil
Thank you very much, usefull source .

Posted: Wed Jul 15, 2009 4:04 pm
by cas
Nice and very useful, thank you.

Posted: Sun Jul 19, 2009 2:27 pm
by BjornF
:D Excellent !

Thank you for making it easier to use SQLite.

Björn