JSON1 support for SQLite

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
cbc700
Posts: 46
Joined: Fri 03 Aug 2007 17:25

JSON1 support for SQLite

Post by cbc700 » Thu 28 Dec 2017 08:01

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.

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: JSON1 support for SQLite

Post by MaximG » Mon 12 Feb 2018 11:32

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.

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: JSON1 support for SQLite

Post by MaximG » Tue 20 Mar 2018 13:10

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"}''));');
   ...

Post Reply