Page 1 of 1

JSON1 support for SQLite

Posted: Thu 28 Dec 2017 08:01
by cbc700
I see from a prior post that the JSON1 SQLite loadable extension has been included/enabled for the dotConnect product. Can this also be done for UniDAC? Thanks.

Re: JSON1 support for SQLite

Posted: Mon 12 Feb 2018 11:32
by MaximG
We will consider a possibility to support JSON1 extension in UniDAC in the next version of our product and will inform you about the results.

Re: JSON1 support for SQLite

Posted: Tue 20 Mar 2018 13:10
by MaximG
We investigated the possibility of using JSON1 extension in UniDAC. Currently, you can work with JSON1 SQLite loadable extension when using our product in the Direct Mode. The following code snippet demonstrates the loading of the 'json1.dll' extension:

Code: Select all

 ...
   UniConnection.ProviderName := 'SQLite';
   UniConnection.SpecificOptions.Values['Direct'] := 'True';
   UniConnection.SpecificOptions.Values['EnableLoadExtension'] := 'True';
   UniConnection.Connect;
   UniConnection.ExecSQL('SELECT load_extension(''json1.dll'')')
   ...
After that, you can create a table with a field of the JSON type and fill it in as follows:

Code: Select all

 ...
   UniConnection.ExecSQL('CREATE TABLE test_table (id INTEGER, json_field JSON);');
   UniConnection.ExecSQL('insert into test_table (id, json_field) values (1, json(''{"name":"donald"}''));');
   UniConnection.ExecSQL('insert into test_table (id, json_field) values (2, json(''{"name":"melania"}''));');
   ...