Base64 function for SQLite
For the MBS Xojo SQL Plugin 25.5, we add a few extensions and include UUID, Base64 and CSV. The base64 extension allows us to make an base64 encoding in a SQL query as the extension adds the base64() function. It converts BLOB to base64 encoded text or back.
To use it in your Xojo application, you need to set the Base64ExtensionEnabled property in the InternalSQLiteLibraryMBS module to true. Then we enable the internal library with the Use method.
Now we connect to an in-memory database to try the new function:
Once we are connected, we can just try the function and encode some value. For demonstration we hard code a BLOB value with the content "hello" using CAST. We pass the BLOB to the base64 function and get back the encoded text.
We create a test table to store labels and blob data in a table.
When we fill the table, we can use base64 decoding right in the INSERT statements. This can be directly as text in the parameter or using a parameter passed separately.
Next we like to query the values back. In the SQL we can query the blob directly and use base64() to get the blob as base64 encoded text.
Finally we can dump the database and show the SQL commands:
Please try the new uuid function and let us know if you need other extensions.
See also InternalSQLiteLibraryMBS module and the SQLite UUID extension blog article.
