SQLite - SPLessons
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

SQLite Extensions

SQLite Extensions

shape Description

SQLite Extensions are the augmentation modules that makes a SQLite scalar capacity "tcc_compile". SQLite Extensions takes one contention which is a string made up of C source code to be on-the-fly accumulated utilizing TinyCC. The SQLite Extensions API is unmistakable amid gathering when "sqlite3.h" is incorporated.

Runtime load extension

shape Description

SQLite can stack expansions at run-time. This element permits the code for expansions to be created and tried independently from the functions and afterward stacked on an as-required premise. Expansions can likewise be statically connected with the operations. The code format appeared underneath will work pretty much and a statically connected augmentation as it does as a run-time loadable expansion aside from that and ought to give the sectional point work and maintain a alternate name to maintain a strategic distance from named  crashes if the application contains two or more augmentations.

SQLite Extensions loading

shape Description

A SQLite augmentation is a DLL or common library. For starting, it has been supplied with SQLite and the name of the record maintaining the DLL or common library and a passage point to instate the expansion. In C programming language code, this data will be transferred by utilizing the sqlite3_load_extension() API. There is additionally a SQL capacity that can be utilized to load augmentations such as load_extension(X,Y). It operates simply like the sqlite3_load_extension() C interface. Both techniques for stacking an augmentation permit us to determine the name of a sectional point for the expansion. And can assent this contention unused and going in a pointer NULL for the sqlite3_load_extension() C-dialect interface or excluding the secondary contention for the load_extension() SQL interface and the augmentation loader rationale will endeavour to make sense of the passage point all alone. On behalf of surveillance reasoning, expansion stacking is alienate by delinquency. Keeping in mind the end goal to utilize either the SQL augmentation or C-dialect stacking capacities, one should first empower expansion stacking utilizing the sqlite3_enable_load_extension() C-dialect API in your application.

shape Syntax

Syntax for running in the SQLite Extensions command-line shell.
.load ./YourCode
The ".load" order with one contention summons sqlite3_load_extension() with the zProc parameter set to NULL, making SQLite first search for a section point named "sqlite3_extension_init" and after that "sqlite3_X_init" where "X" is gotten from the filename. In the event that your augmentation has a section point with an alternate name, just supply that name as the second contention.

shape Examples

For loading an extension using sqlite3 load extension. [c].load ./YourCode nonstandard_entry_point[/c]

Compiling a loadable extension

shape Description

Loadable augmentations are written in C-code. To compile them in the operating system based on  unix paltform, the code will be as follows. gcc -g -fPIC -shared YourCode.c -o YourCode.so To compile a mutual library on a Mac, utilize the below command. gcc -g -fPIC -dynamiclib YourCode.c -o YourCode.dylib

Programming loaded extensions

shape Description

The proframming loaded extensions contain the following elements.

Summary

shape Key Points

  • SQLite Extensions - Is connected with database records stored in the SQLite database position.
  • Runtime load extension - This will stack the extensions at runtime.
  • Extension loading - Are common library or DLL extension.