### Setting up WASI-SDK on Ubuntu Source: https://sqlite.org/cli.html/wasm/doc/ckout/building This snippet provides a step-by-step guide to clone, build, and install the wasi-sdk on an Ubuntu-like Linux system. It includes commands for cloning the repository, installing dependencies, compiling the SDK, and creating a symbolic link to the installation directory for system-wide access. ```Bash $ git clone --recursive https://github.com/WebAssembly/wasi-sdk.git $ cd wasi-sdk $ sudo apt install ninja-build cmake clang $ NINJA_FLAGS=-v make package # ^^^^ go order a pizza, wait for it to arrive, eat it, and # check back. Maybe it'll be done by then. Maybe. As of this writing, # it has to compile more than 3000 C++ files. $ sudo ln -s $PWD/build/wasi-sdk-* /opt/wasi-sdk # ^^^^^^^ /opt/wasi-sdk is a magic path name for these tools ``` -------------------------------- ### Setting up wasi-sdk on Ubuntu Source: https://sqlite.org/cli.html/wasm/doc/trunk/building This snippet provides a step-by-step guide to clone, build, and install the wasi-sdk on an Ubuntu-style Linux system. It includes commands for installing necessary dependencies like ninja-build, cmake, and clang, and notes the potentially long compilation time for the SDK. ```shell $ git clone --recursive https://github.com/WebAssembly/wasi-sdk.git $ cd wasi-sdk $ sudo apt install ninja-build cmake clang $ NINJA_FLAGS=-v make package # ^^^^ go order a pizza, wait for it to arrive, eat it, and # check back. Maybe it'll be done by then. Maybe. As of this writing, # it has to compile more than 3000 C++ files. $ sudo ln -s $PWD/build/wasi-sdk-* /opt/wasi-sdk # ^^^^^^^ /opt/wasi-sdk is a magic path name for these tools ``` -------------------------------- ### Example: Compiling SQLite on Unix-like Systems Source: https://sqlite.org/cli.html/src/attachdownload/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/compile-for-windows This snippet provides a step-by-step example of compiling SQLite on Unix-like systems. It covers installing prerequisites, unpacking the source, configuring the build, and building various SQLite components and tools using `make`. ```Shell apt install gcc make tcl-dev ;# Make sure you have all the necessary build tools tar xzf sqlite.tar.gz ;# Unpack the source tree into "sqlite" mkdir bld ;# Build will occur in a sibling directory cd bld ;# Change to the build directory ../sqlite/configure ;# Run the configure script make sqlite3 ;# Builds the "sqlite3" command-line tool make sqlite3.c ;# Build the "amalgamation" source file make sqldiff ;# Builds the "sqldiff" command-line tool # Makefile targets below this point require tcl-dev make tclextension-install ;# Build and install the SQLite TCL extension make devtest ;# Run development tests make releasetest ;# Run full release tests make sqlite3_analyzer ;# Builds the "sqlite3_analyzer" tool ``` -------------------------------- ### Compiling SQLite on Unix-like Systems Source: https://sqlite.org/cli.html/src/raw/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/lemon Provides a step-by-step guide to compile SQLite on Unix-like systems, including installing dependencies, unpacking source, creating a build directory, running configure, and executing various make targets for tools like `sqlite3`, `sqldiff`, and `sqlite3_analyzer`, as well as testing and TCL extension installation. ```Shell apt install gcc make tcl-dev ;# Make sure you have all the necessary build tools tar xzf sqlite.tar.gz ;# Unpack the source tree into "sqlite" mkdir bld ;# Build will occur in a sibling directory cd bld ;# Change to the build directory ../sqlite/configure ;# Run the configure script make sqlite3 ;# Builds the "sqlite3" command-line tool make sqlite3.c ;# Build the "amalgamation" source file make sqldiff ;# Builds the "sqldiff" command-line tool # Makefile targets below this point require tcl-dev make tclextension-install ;# Build and install the SQLite TCL extension make devtest ;# Run development tests make releasetest ;# Run full release tests make sqlite3_analyzer ;# Builds the "sqlite3_analyzer" tool ``` -------------------------------- ### Demonstrating SQLite generate_series Usage with SQL Examples Source: https://sqlite.org/cli.html/src/raw/e212edb2aa00cc778bf29a6d51c51ebb187fae36267f281b484410a3df065dde Illustrates various SQL queries using the `generate_series` virtual table. Examples show how to specify start, stop, and step values, and how `LIMIT` affects the output sequence. This demonstrates the flexibility of the function's arguments. ```SQL SELECT * FROM generate_series(0,100,5); SELECT * FROM generate_series(0,100); SELECT * FROM generate_series(20) LIMIT 10; SELECT * FROM generate_series(0,-100,-5); SELECT * FROM generate_series(0,-1); ``` -------------------------------- ### Compile SQLite on Unix-like Systems Source: https://sqlite.org/cli.html/src/raw/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/compile-for-windows Provides a step-by-step example of compiling SQLite on Unix-like systems, including installing build tools, unpacking source, configuring, and building various command-line tools and extensions using `make`. ```Shell apt install gcc make tcl-dev ;# Make sure you have all the necessary build tools tar xzf sqlite.tar.gz ;# Unpack the source tree into "sqlite" mkdir bld ;# Build will occur in a sibling directory cd bld ;# Change to the build directory ../sqlite/configure ;# Run the configure script make sqlite3 ;# Builds the "sqlite3" command-line tool make sqlite3.c ;# Build the "amalgamation" source file make sqldiff ;# Builds the "sqldiff" command-line tool # Makefile targets below this point require tcl-dev make tclextension-install ;# Build and install the SQLite TCL extension make devtest ;# Run development tests make releasetest ;# Run full release tests make sqlite3_analyzer ;# Builds the "sqlite3_analyzer" tool ``` -------------------------------- ### Basic SQLite Compilation Steps on Unix-like Systems Source: https://sqlite.org/cli.html/src/attachdownload/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/lemon This snippet provides a sequence of shell commands to set up the build environment, unpack the SQLite source, configure the build, and compile various SQLite tools and components using 'make'. It highlights common targets like 'sqlite3', 'sqldiff', and 'tclextension-install'. ```Bash apt install gcc make tcl-dev ;# Make sure you have all the necessary build tools tar xzf sqlite.tar.gz ;# Unpack the source tree into "sqlite" mkdir bld ;# Build will occur in a sibling directory cd bld ;# Change to the build directory ../sqlite/configure ;# Run the configure script make sqlite3 ;# Builds the "sqlite3" command-line tool make sqlite3.c ;# Build the "amalgamation" source file make sqldiff ;# Builds the "sqldiff" command-line tool # Makefile targets below this point require tcl-dev make tclextension-install ;# Build and install the SQLite TCL extension make devtest ;# Run development tests make releasetest ;# Run full release tests make sqlite3_analyzer ;# Builds the "sqlite3_analyzer" tool ``` -------------------------------- ### Example kvtest Workflow: Init, Export, Run Source: https://sqlite.org/cli.html/src/raw/6e0228409ea7ca0497dad503fbd109badb5e59545d131014b6aaac68b56f484a A sequence of commands demonstrating a typical workflow for `kvtest`: initializing a SQLite database, exporting its contents to a directory, and then running performance tests against both the SQLite database and the exported files. ```Bash ./kvtest init x1.db --count 100000 --size 10000 mkdir x1 ./kvtest export x1.db x1 ./kvtest run x1.db --count 10000 --max-id 1000000 ./kvtest run x1 --count 10000 --max-id 1000000 ``` -------------------------------- ### Database Setup for SQLite Aggregate Window Function Examples Source: https://sqlite.org/cli.html/windowfunctions Provides the SQL statements to create and populate a sample table `t1` with data. This setup is used as a prerequisite for demonstrating various aggregate window functions in subsequent examples. ```SQL CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c); INSERT INTO t1 VALUES (1, 'A', 'one' ), (2, 'B', 'two' ), (3, 'C', 'three'), (4, 'D', 'one' ), (5, 'E', 'two' ), (6, 'F', 'three'), (7, 'G', 'one' ); ``` -------------------------------- ### Windows Command Line: Build and Test TCL 9.0 and SQLite Extension Source: https://sqlite.org/cli.html/src/doc/tip/doc/tcl-extension-testing Provides a step-by-step guide to build and install TCL 9.0, followed by building, installing, and verifying the SQLite TCL extension on a Windows system using NMAKE. Note that 'release' and 'install' targets must be invoked separately. ```cmd mkdir %TCLBUILD%\tcl90 cd %TCLSOURCE%\win fossil up core-9-0-0 fossil clean -x set INSTALLDIR=%TCLBUILD%\tcl90 nmake /f makefile.vc release nmake /f makefile.vc install cd %SQLITESOURCE% fossil clean -x set TCLDIR=%TCLBUILD%\tcl90 set PATH=%TCLBUILD%\tcl90\bin;%ORIGINALPATH% set TCLSH_CMD=%TCLBUILD%\tcl90\bin\tclsh90.exe nmake /f Makefile.msc tclextension-install nmake /f Makefile.msc tclextension-verify tclsh90 test/testrunner.tcl release --explain ``` -------------------------------- ### Build SQLite and Tools on Unix-like Systems Source: https://sqlite.org/cli.html/src/attachdownload/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/lemon Detailed steps to prepare the environment, unpack source, configure, and build the `sqlite3` CLI, `sqlite3.c` amalgamation, `sqldiff`, TCL extension, and run tests. Requires `gcc`, `make`, and `tcl-dev`. ```Shell apt install gcc make tcl-dev ;# Make sure you have all the necessary build tools tar xzf sqlite.tar.gz ;# Unpack the source tree into "sqlite" mkdir bld ;# Build will occur in a sibling directory cd bld ;# Change to the build directory ../sqlite/configure ;# Run the configure script make sqlite3 ;# Builds the "sqlite3" command-line tool make sqlite3.c ;# Build the "amalgamation" source file make sqldiff ;# Builds the "sqldiff" command-line tool # Makefile targets below this point require tcl-dev make tclextension-install ;# Build and install the SQLite TCL extension make devtest ;# Run development tests make releasetest ;# Run full release tests make sqlite3_analyzer ;# Builds the "sqlite3_analyzer" tool ``` -------------------------------- ### Windows Command Line: Build and Test TCL 8.6 and SQLite Extension Source: https://sqlite.org/cli.html/src/doc/tip/doc/tcl-extension-testing Provides a step-by-step guide to build and install TCL 8.6, followed by building, installing, and verifying the SQLite TCL extension on a Windows system using NMAKE. Note that 'release' and 'install' targets must be invoked separately. ```cmd mkdir %TCLBUILD%\tcl86 cd %TCLSOURCE%\win fossil up core-8-6-16 fossil clean -x set INSTALLDIR=%TCLBUILD%\tcl86 nmake /f makefile.vc release nmake /f makefile.vc install cd %SQLITESOURCE% fossil clean -x set TCLDIR=%TCLBUILD%\tcl86 set PATH=%TCLBUILD%\tcl86\bin;%ORIGINALPATH% set TCLSH_CMD=%TCLBUILD%\tcl86\bin\tclsh86t.exe nmake /f Makefile.msc tclextension-install nmake /f Makefile.msc tclextension-verify tclsh86t test/testrunner.tcl release --explain ``` -------------------------------- ### Tcl: Development Environment Setup and Server Start Source: https://sqlite.org/cli.html/src/ext/checklist/3071100/self This Tcl code block configures the `DATADIR` variable for development environments, specifically when running on localhost with a specific port and IP. It checks if `DATADIR` is not already set and if the request originates from a local development setup. Finally, it starts the web application server using `wapp-start` with command-line arguments. ```Tcl if {![file exists $DATADIR] && [info exists HTTP_HOST] && [string match {localhost:808[0-9]} $env(HTTP_HOST)] && $env(REMOTE_ADDR)=="127.0.0.1" && $env(REQUEST_SCHEME)=="http"} { set DATADIR $env(DOCUMENT_ROOT)/dbs } wapp-start $::argv ``` -------------------------------- ### Compile SQLite on Unix-like Systems with Make Source: https://sqlite.org/cli.html/src/attachdownload/doc/doc/doc/doc/lemon This snippet demonstrates the standard build process for SQLite on Unix-like systems. It covers installing prerequisites, unpacking the source, configuring the build directory, and executing various `make` targets to build tools like `sqlite3`, `sqldiff`, and `sqlite3_analyzer`, as well as running tests and installing the TCL extension. ```Shell apt install gcc make tcl-dev ;# Make sure you have all the necessary build tools tar xzf sqlite.tar.gz ;# Unpack the source tree into "sqlite" mkdir bld ;# Build will occur in a sibling directory cd bld ;# Change to the build directory ../sqlite/configure ;# Run the configure script make sqlite3 ;# Builds the "sqlite3" command-line tool make sqlite3.c ;# Build the "amalgamation" source file make sqldiff ;# Builds the "sqldiff" command-line tool # Makefile targets below this point require tcl-dev make tclextension-install ;# Build and install the SQLite TCL extension make devtest ;# Run development tests make releasetest ;# Run full release tests make sqlite3_analyzer ;# Builds the "sqlite3_analyzer" tool ``` -------------------------------- ### Initialize SQLite Virtual Table Explanation Module and Extension (C) Source: https://sqlite.org/cli.html/src/file/ext/misc/explain This C code snippet demonstrates the initialization process for an SQLite extension that includes a virtual table explanation module. It shows how to create a virtual table module using `sqlite3_create_module` and how to set up the extension's entry point using `SQLITE_EXTENSION_INIT2` for proper API routine access. The `sqlite3_explain_init` function serves as the main entry point for the extension, which in turn calls `sqlite3ExplainVtabInit` to register the 'explain' module. ```C /* xIntegrity */ }; #endif /* SQLITE_OMIT_VIRTUALTABLE */ int sqlite3ExplainVtabInit(sqlite3 *db){ int rc = SQLITE_OK; #ifndef SQLITE_OMIT_VIRTUALTABLE rc = sqlite3_create_module(db, "explain", &explainModule, 0); #endif return rc; } #ifdef _WIN32 __declspec(dllexport) #endif int sqlite3_explain_init( sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi ){ int rc = SQLITE_OK; SQLITE_EXTENSION_INIT2(pApi); #ifndef SQLITE_OMIT_VIRTUALTABLE rc = sqlite3ExplainVtabInit(db); #endif return rc; } ``` -------------------------------- ### Install and Initialize PostgreSQL Source: https://sqlite.org/cli.html/forum/forumpost/a5fc33cf9d8f4ff5 Steps to install the compiled PostgreSQL binaries, create a dedicated user and data directory, initialize the database cluster, start the PostgreSQL server, and create a default database. ```bash sudo su make install adduser postgres rm -rf /usr/local/pgsql/data mkdir /usr/local/pgsql/data chown -R postgres /usr/local/pgsql/data su - postgres /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start /usr/local/pgsql/bin/createdb postgresdb /usr/local/pgsql/bin/psql postgresdb /usr/local/pgsql/bin/createuser -s {username} /usr/local/pgsql/bin/createdb {username} /usr/local/pgsql/bin/psql =# alter {username} with superuser ``` -------------------------------- ### Install Emscripten SDK on Linux Source: https://sqlite.org/cli.html/wasm/doc/ckout/emscripten Provides commands to clone the Emscripten SDK repository, install the latest SDK tools, and activate them for the current user. This setup is typically a one-time process. ```Bash # Clone the emscripten repository: $ sudo apt install git $ git clone https://github.com/emscripten-core/emsdk.git $ cd emsdk # Download and install the latest SDK tools: $ ./emsdk install latest # Make the "latest" SDK "active" for the current user: $ ./emsdk activate latest ``` -------------------------------- ### Compiling SQLite on Unix-like Systems Source: https://sqlite.org/cli.html/src/attachdownload/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/lemon Demonstrates the typical build process for SQLite on Unix-like systems, including installing dependencies, unpacking source, creating a build directory, running configure, and building various tools and extensions. It highlights common `make` targets. ```Shell apt install gcc make tcl-dev ;# Make sure you have all the necessary build tools tar xzf sqlite.tar.gz ;# Unpack the source tree into "sqlite" mkdir bld ;# Build will occur in a sibling directory cd bld ;# Change to the build directory ../sqlite/configure ;# Run the configure script make sqlite3 ;# Builds the "sqlite3" command-line tool make sqlite3.c ;# Build the "amalgamation" source file make sqldiff ;# Builds the "sqldiff" command-line tool # Makefile targets below this point require tcl-dev make tclextension-install ;# Build and install the SQLite TCL extension make devtest ;# Run development tests make releasetest ;# Run full release tests make sqlite3_analyzer ;# Builds the "sqlite3_analyzer" tool ``` -------------------------------- ### Compiling SQLite on Unix-like Systems Source: https://sqlite.org/cli.html/src/attachdownload/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/compile-for-windows Demonstrates the typical build process for SQLite on Unix-like systems, including installing necessary build tools, unpacking the source, creating a build directory, running the configure script, and building various SQLite components like the command-line tool, amalgamation source, and utilities using `make`. ```shell apt install gcc make tcl-dev ;# Make sure you have all the necessary build tools tar xzf sqlite.tar.gz ;# Unpack the source tree into "sqlite" mkdir bld ;# Build will occur in a sibling directory cd bld ;# Change to the build directory ../sqlite/configure ;# Run the configure script make sqlite3 ;# Builds the "sqlite3" command-line tool make sqlite3.c ;# Build the "amalgamation" source file make sqldiff ;# Builds the "sqldiff" command-line tool # Makefile targets below this point require tcl-dev make tclextension-install ;# Build and install the SQLite TCL extension make devtest ;# Run development tests make releasetest ;# Run full release tests make sqlite3_analyzer ;# Builds the "sqlite3_analyzer" tool ``` -------------------------------- ### Remote SQLite WASM Testing Setup with SSH Tunnel Source: https://sqlite.org/cli.html/src/dir/ext/wasm This section details the steps required to test SQLite WASM applications on a remote machine using an SSH tunnel. It covers installing prerequisites, building the WASM project, starting the `althttpd` server on the remote host with `SharedArrayBuffer` support, and then establishing a local SSH tunnel to access the remote server from a local web browser. ```Shell # Remote: Install git, emsdk, and althttpd (version 2022-09-26 or newer) # Remote: Install the SQLite source tree. CD to ext/wasm make ``` ```Shell # Remote: Start althttpd server althttpd --enable-sab --port 8080 --popup ``` ```Shell # Local: Establish SSH tunnel ssh -L 8180:localhost:8080 remote ``` ```Shell # Local: Point your web-browser at the tunneled address http://localhost:8180/index.html ``` -------------------------------- ### kvtest Command-Line Usage Examples Source: https://sqlite.org/cli.html/src/file/test/kvtest Demonstrates a typical workflow for using the `kvtest` utility, including initializing a database, exporting its contents to a directory, and running performance tests against both the SQLite database and the exported files. ```Shell ./kvtest init x1.db --count 100000 --size 10000 mkdir x1 ./kvtest export x1.db x1 ./kvtest run x1.db --count 10000 --max-id 1000000 ./kvtest run x1 --count 10000 --max-id 1000000 ``` -------------------------------- ### /sqlite3-api-build-version.js Source: https://sqlite.org/cli.html/wasm/doc/ckout/building Gets created by the build process and populates the `sqlite3.version` object. ```APIDOC Module: sqlite3-api-build-version.js Origin: Created by the build process. Purpose: Populates the `sqlite3.version` object. ``` -------------------------------- ### Compile SQLite on Unix-like Systems Source: https://sqlite.org/cli.html/src/attachdownload/doc/doc/doc/doc/doc/doc/doc/doc/doc/lemon Demonstrates the typical steps to compile SQLite on Unix-like systems, including installing dependencies, unpacking source, creating a build directory, running configure, and building various tools and extensions using 'make'. ```Shell apt install gcc make tcl-dev ;# Make sure you have all the necessary build tools tar xzf sqlite.tar.gz ;# Unpack the source tree into "sqlite" mkdir bld ;# Build will occur in a sibling directory cd bld ;# Change to the build directory ../sqlite/configure ;# Run the configure script make sqlite3 ;# Builds the "sqlite3" command-line tool make sqlite3.c ;# Build the "amalgamation" source file make sqldiff ;# Builds the "sqldiff" command-line tool # Makefile targets below this point require tcl-dev make tclextension-install ;# Build and install the SQLite TCL extension make devtest ;# Run development tests make releasetest ;# Run full release tests make sqlite3_analyzer ;# Builds the "sqlite3_analyzer" tool ``` -------------------------------- ### Tcl Configuration: Development Data Directory Setup and Server Start Source: https://sqlite.org/cli.html/src/ext/checklist/3080700/self This Tcl code block configures the `DATADIR` variable for development environments, specifically when running on localhost with a specific port and IP. It checks if `DATADIR` is not already set and if the request originates from a local development setup. Finally, it starts the web application server using `wapp-start` with command-line arguments. ```Tcl if {![file exists $DATADIR] && [info exists HTTP_HOST] && [string match {localhost:808[0-9]} $env(HTTP_HOST)] && $env(REMOTE_ADDR)=="127.0.0.1" && $env(REQUEST_SCHEME)=="http"} { set DATADIR $env(DOCUMENT_ROOT)/dbs } wapp-start $::argv ``` -------------------------------- ### Start althttpd for WASM Testing Source: https://sqlite.org/cli.html/src/ext/checklist/3450000/history Starts the `althttpd` web server with Shared Array Buffer (SAB) enabled and serves `index.html`. This command is part of the setup for testing SQLite's WASM (WebAssembly) functionality. ```Shell althttpd --enable-sab --page index.html ``` -------------------------------- ### Building and Running SQLite Test Fixture Source: https://sqlite.org/cli.html/src/attachdownload/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/lemon Commands to build the `testfixture` augmented TCL interpreter on Unix and Windows, and an example of how to run an individual test using it. ```Shell make testfixture ``` ```Makefile nmake /f Makefile.msc testfixture.exe ``` ```Shell testfixture test/main.test ``` -------------------------------- ### JavaScript Example: Manually Installing C-style Callback for sqlite3_exec() Source: https://sqlite.org/cli.html/wasm/doc/trunk/api-c-style This advanced JavaScript example shows how to manually install a C-style callback function into WASM using `wasm.installFunction()` and then pass its pointer to `sqlite3_exec()`. It includes helper logic for converting C arguments (like `char**` arrays) into JavaScript arrays or strings, and demonstrates proper resource management by uninstalling the function in a `finally` block. ```JavaScript const pCb = wasm.installFunction('i(pipp)', function(pVoid,nCols,aVals,aCols){ // wasm.cArgvToJs() can be used to convert aVals and aCols to arrays: const vals = wasm.cArgvToJs(nCols, aVals); // Noting that the aCols list is constant across each sqlite3_exec() // invocation and can be cached _if_ this function will only ever // be used with a single specific query. // Alternately, individual name and value columns can be converted // to JS strings like: const strAt = (ndx)=>{ return ndx SQLITE_EXTENSION_INIT1 ``` -------------------------------- ### Building SQLite with WASI-SDK Source: https://sqlite.org/cli.html/wasm/doc/ckout/building After installing wasi-sdk, these commands configure and build the SQLite source tree to use the installed WASI SDK. The `configure` script is used to specify the path to the SDK, followed by `make` to compile the project. ```Bash $ ./configure --with-wasi-sdk=/opt/wasi-sdk $ make ``` -------------------------------- ### Build and Test TCL 8.6 and SQLite TCL Extension on Windows Source: https://sqlite.org/cli.html/src/artifact/b88861804f This sequence of commands guides the user through building TCL 8.6, followed by building and installing the SQLite TCL extension, and finally verifying the installation by running tests. It emphasizes the requirement to invoke 'release' and 'install' targets using separate 'nmake' commands. ```Batch mkdir %TCLBUILD%\tcl86 cd %TCLSOURCE%\win fossil up core-8-6-16 fossil clean -x set INSTALLDIR=%TCLBUILD%\tcl86 nmake /f makefile.vc release nmake /f makefile.vc install cd %SQLITESOURCE% fossil clean -x set TCLDIR=%TCLBUILD%\tcl86 set PATH=%TCLBUILD%\tcl86\bin;%ORIGINALPATH% set TCLSH_CMD=%TCLBUILD%\tcl86\bin\tclsh86t.exe nmake /f Makefile.msc tclextension-install nmake /f Makefile.msc tclextension-verify tclsh86t test/testrunner.tcl release --explain ``` -------------------------------- ### Asynchronous SQLite OPFS SAH Pool VFS Installation with Promise Source: https://sqlite.org/cli.html/wasm/doc/trunk/persistence Installs the `opfs-sahpool` VFS using a Promise-based approach, allowing for asynchronous setup and providing access to `poolUtil` for managing the VFS instance and its associated utilities. ```javascript sqlite3.installOpfsSAHPoolVfs().then((poolUtil)=>{ // poolUtil contains utilities for managing the pool, described below. // VFS "opfs-sahpool" is now available, and poolUtil.OpfsSAHPoolDb // is a subclass of sqlite3.oo1.DB to simplify usage with // the oo1 API. }).catch(...); ``` -------------------------------- ### Compile SQLite on Unix-like Systems Source: https://sqlite.org/cli.html/src/raw/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/lemon Demonstrates the typical build process for SQLite on Unix-like systems, including installing dependencies, unpacking source, creating a build directory, running `configure`, and executing various `make` targets for different components like `sqlite3`, `sqlite3.c` (amalgamation), `sqldiff`, TCL extension, and test suites. Notes that targets below `tclextension-install` require TCL development libraries. ```Shell apt install gcc make tcl-dev ;# Make sure you have all the necessary build tools tar xzf sqlite.tar.gz ;# Unpack the source tree into "sqlite" mkdir bld ;# Build will occur in a sibling directory cd bld ;# Change to the build directory ../sqlite/configure ;# Run the configure script make sqlite3 ;# Builds the "sqlite3" command-line tool make sqlite3.c ;# Build the "amalgamation" source file make sqldiff ;# Builds the "sqldiff" command-line tool # Makefile targets below this point require tcl-dev make tclextension-install ;# Build and install the SQLite TCL extension make devtest ;# Run development tests make releasetest ;# Run full release tests make sqlite3_analyzer ;# Builds the "sqlite3_analyzer" tool ``` -------------------------------- ### Compile SQLite on Unix-like Systems Source: https://sqlite.org/cli.html/src/attachdownload/doc/doc/doc/doc/doc/doc/doc/doc/compile-for-windows Demonstrates the typical build process for SQLite on Unix-like systems, including installing dependencies, unpacking source, creating a build directory, running `configure`, and using `make` for various targets like `sqlite3`, `sqlite3.c`, `sqldiff`, TCL extension, and tests. ```Shell apt install gcc make tcl-dev ;# Make sure you have all the necessary build tools tar xzf sqlite.tar.gz ;# Unpack the source tree into "sqlite" mkdir bld ;# Build will occur in a sibling directory cd bld ;# Change to the build directory ../sqlite/configure ;# Run the configure script make sqlite3 ;# Builds the "sqlite3" command-line tool make sqlite3.c ;# Build the "amalgamation" source file make sqldiff ;# Builds the "sqldiff" command-line tool # Makefile targets below this point require tcl-dev make tclextension-install ;# Build and install the SQLite TCL extension make devtest ;# Run development tests make releasetest ;# Run full release tests make sqlite3_analyzer ;# Builds the "sqlite3_analyzer" tool ``` -------------------------------- ### Building SQLite Components and Running Tests Requiring TCL on Windows Source: https://sqlite.org/cli.html/src/doc/trunk/doc/compile-for-windows Examples of `nmake` commands for SQLite build targets that necessitate a prior TCL installation, as described in step 3. This includes installing the TCL extension, running development tests, release tests, and building the `sqlite3_analyzer.exe` utility. If TCL is installed in a non-default location, the `TCLDIR` option must be specified. ```Batch nmake /f makefile.msc tclextension-install nmake /f makefile.msc devtest nmake /f makefile.msc releasetest nmake /f makefile.msc sqlite3_analyzer.exe ``` -------------------------------- ### Compile SQLite on Unix-like Systems Source: https://sqlite.org/cli.html/src/raw/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/lemon Demonstrates the standard build process for SQLite on Unix-like systems, including installing dependencies, unpacking source, creating a build directory, running `configure`, and using `make` for various targets like `sqlite3`, `sqlite3.c`, `sqldiff`, and test targets. Requires `gcc`, `make`, and `tcl-dev`. ```Shell apt install gcc make tcl-dev ;# Make sure you have all the necessary build tools tar xzf sqlite.tar.gz ;# Unpack the source tree into "sqlite" mkdir bld ;# Build will occur in a sibling directory cd bld ;# Change to the build directory ../sqlite/configure ;# Run the configure script make sqlite3 ;# Builds the "sqlite3" command-line tool make sqlite3.c ;# Build the "amalgamation" source file make sqldiff ;# Builds the "sqldiff" command-line tool # Makefile targets below this point require tcl-dev make tclextension-install ;# Build and install the SQLite TCL extension make devtest ;# Run development tests make releasetest ;# Run full release tests make sqlite3_analyzer ;# Builds the "sqlite3_analyzer" tool ``` -------------------------------- ### Get String Form of SQLite Constant Source: https://sqlite.org/cli.html/wasm/doc/ckout/api-c-style Example demonstrating how to use the `sqlite3_js_rc_str` function to retrieve the string representation of an SQLite constant, such as `SQLITE_ERROR`. ```JavaScript sqlite3_js_rc_str(sqlite3.capi.SQLITE_ERROR); // ==> "SQLITE_ERROR" ``` -------------------------------- ### Build SQLite Targets Requiring TCL on Windows Source: https://sqlite.org/cli.html/src/file/doc/compile-for-windows Examples of nmake commands to compile SQLite targets that depend on a TCL installation, such as tclextension-install, devtest, releasetest, and sqlite3_analyzer.exe. If TCL is installed in a custom directory, the TCLDIR= option must be appended to the nmake command. ```Batch nmake /f makefile.msc tclextension-install nmake /f makefile.msc devtest nmake /f makefile.msc releasetest nmake /f makefile.msc sqlite3_analyzer.exe ``` -------------------------------- ### Run SQLite Individual Test Source: https://sqlite.org/cli.html/src/attachdownload/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/lemon Example command to execute a specific SQLite test script using the 'testfixture' interpreter. ```Shell testfixture test/main.test ``` -------------------------------- ### Activate HTTP Server (C) Source: https://sqlite.org/cli.html/althttpd/raw/4d9e13b300263607ecdfe525ddbd70445513ea021cc668f928b263dde2e06778 This C code block attempts to start an HTTP server. It validates the requested port range (`mnPort` to `mxPort`) and calls the `http_server` function. If the server fails to start, it logs a malfunction with error code 520. ```C /* Activate the server, if requested */ if( mnPort>0 && mnPort<=mxPort && http_server(mnPort, mxPort, tlsPort, bLocalhost, zPage, &httpConnection) ){ Malfunction(520, /* LOG: server startup failed */ "failed to start server"); } ``` -------------------------------- ### Compile SQLite on Unix-like Systems Source: https://sqlite.org/cli.html/src/raw/doc/lemon Provides a step-by-step example for compiling SQLite on Unix-like systems. It covers installing necessary build tools, unpacking the source, creating a build directory, running the configure script, and executing various make targets to build the `sqlite3` command-line tool, the `sqlite3.c` amalgamation, `sqldiff`, TCL extension, and development/release tests. ```Shell apt install gcc make tcl-dev ;# Make sure you have all the necessary build tools tar xzf sqlite.tar.gz ;# Unpack the source tree into "sqlite" mkdir bld ;# Build will occur in a sibling directory cd bld ;# Change to the build directory ../sqlite/configure ;# Run the configure script make sqlite3 ;# Builds the "sqlite3" command-line tool make sqlite3.c ;# Build the "amalgamation" source file make sqldiff ;# Builds the "sqldiff" command-line tool # Makefile targets below this point require tcl-dev make tclextension-install ;# Build and install the SQLite TCL extension make devtest ;# Run development tests make releasetest ;# Run full release tests make sqlite3_analyzer ;# Builds the "sqlite3_analyzer" tool ``` -------------------------------- ### Compile SQLite on Unix-like Systems Source: https://sqlite.org/cli.html/src/attachdownload/doc/doc/doc/lemon Demonstrates the typical steps to compile SQLite on Unix-like systems, including installing dependencies, unpacking source, creating a build directory, running 'configure', and building various tools and extensions using 'make'. ```Shell apt install gcc make tcl-dev ;# Make sure you have all the necessary build tools tar xzf sqlite.tar.gz ;# Unpack the source tree into "sqlite" mkdir bld ;# Build will occur in a sibling directory cd bld ;# Change to the build directory ../sqlite/configure ;# Run the configure script make sqlite3 ;# Builds the "sqlite3" command-line tool make sqlite3.c ;# Build the "amalgamation" source file make sqldiff ;# Builds the "sqldiff" command-line tool # Makefile targets below this point require tcl-dev make tclextension-install ;# Build and install the SQLite TCL extension make devtest ;# Run development tests make releasetest ;# Run full release tests make sqlite3_analyzer ;# Builds the "sqlite3_analyzer" tool ``` -------------------------------- ### Compiling SQLite Components Requiring TCL Source: https://sqlite.org/cli.html/src/doc/tip/doc/compile-for-windows Examples of nmake commands to build SQLite components that require a TCL installation, such as the TCL extension, development tests, release tests, and the sqlite3_analyzer.exe utility. If TCL is installed in a non-default location, the 'TCLDIR' argument must be provided. ```Command Prompt nmake /f makefile.msc tclextension-install nmake /f makefile.msc devtest nmake /f makefile.msc releasetest nmake /f makefile.msc sqlite3_analyzer.exe ``` -------------------------------- ### Configure SQLite for Release on Unix-like Systems Source: https://sqlite.org/cli.html/src/attachdownload/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/lemon Command to run the `configure` script with options to enable all features, typically used for optimized release builds. ```Shell ../sqlite/configure --enable-all ``` -------------------------------- ### Install TCL Development Libraries for SQLite Source: https://sqlite.org/cli.html/src/doc/tip/doc/compile-for-unix These commands guide the optional installation of TCL development libraries into a local directory, which is required for running SQLite tests and building the TCL extension. As of 2024-10-25, TCL is not required for common build targets like `sqlite3.c` or the `sqlite3` command-line tool. ```Shell mkdir $HOME/local ``` ```Shell ./configure --prefix=$HOME/local ``` ```Shell make install ``` -------------------------------- ### Building and Running SQLite Tests Source: https://sqlite.org/cli.html/src/attachdownload/doc/doc/doc/doc/doc/doc/doc/doc/doc/lemon Commands to build the 'testfixture' augmented TCL interpreter on Unix and Windows platforms, and an example of how to execute individual tests using the built interpreter. ```Shell make testfixture ``` ```Shell nmake /f Makefile.msc testfixture.exe ``` ```Shell testfixture test/main.test ``` -------------------------------- ### Compiling SQLite on Unix-like Systems Source: https://sqlite.org/cli.html/src/attachdownload/doc/doc/doc/doc/compile-for-windows Provides a step-by-step example of compiling SQLite on Unix-like systems, including installing dependencies, unpacking source, creating a build directory, configuring, and building various SQLite tools and extensions using `make`. ```Shell apt install gcc make tcl-dev ;# Make sure you have all the necessary build tools tar xzf sqlite.tar.gz ;# Unpack the source tree into "sqlite" mkdir bld ;# Build will occur in a sibling directory cd bld ;# Change to the build directory ../sqlite/configure ;# Run the configure script make sqlite3 ;# Builds the "sqlite3" command-line tool make sqlite3.c ;# Build the "amalgamation" source file make sqldiff ;# Builds the "sqldiff" command-line tool # Makefile targets below this point require tcl-dev make tclextension-install ;# Build and install the SQLite TCL extension make devtest ;# Run development tests make releasetest ;# Run full release tests make sqlite3_analyzer ;# Builds the "sqlite3_analyzer" tool ``` -------------------------------- ### SQLite CLI: Get Last Error Code Source: https://sqlite.org/cli.html/tclsqlite Returns the numeric error code that resulted from the most recent SQLite operation. ```APIDOC Method: errorcode Description: Returns the numeric error code that resulted from the most recent SQLite operation. Returns: Integer error code. ``` -------------------------------- ### Compiling SQLite on Unix-like Systems Source: https://sqlite.org/cli.html/src/attachdownload/doc/doc/doc/doc/doc/doc/doc/compile-for-windows Demonstrates the typical build process for SQLite on Unix-like systems, including installing dependencies, unpacking source, creating a build directory, running `configure`, and executing various `make` targets for tools like `sqlite3`, `sqldiff`, `sqlite3.c` (amalgamation), and testing utilities. ```Shell apt install gcc make tcl-dev ;# Make sure you have all the necessary build tools tar xzf sqlite.tar.gz ;# Unpack the source tree into "sqlite" mkdir bld ;# Build will occur in a sibling directory cd bld ;# Change to the build directory ../sqlite/configure ;# Run the configure script make sqlite3 ;# Builds the "sqlite3" command-line tool make sqlite3.c ;# Build the "amalgamation" source file make sqldiff ;# Builds the "sqldiff" command-line tool # Makefile targets below this point require tcl-dev make tclextension-install ;# Build and install the SQLite TCL extension make devtest ;# Run development tests make releasetest ;# Run full release tests make sqlite3_analyzer ;# Builds the "sqlite3_analyzer" tool ``` -------------------------------- ### Build and Serve SQLite WASM Locally Source: https://sqlite.org/cli.html/src/dir/ext/wasm This command builds the SQLite WASM project and starts a local HTTP server, typically opening the system's browser to the index page. It's the simplest way to get started with local development and access most test and demo applications. ```Shell $ make httpd ``` -------------------------------- ### Configure SQLite for Release Build on Unix-like Systems Source: https://sqlite.org/cli.html/src/attachdownload/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/doc/compile-for-windows Illustrates the `configure` command used by core developers for release builds on Unix-like systems, enabling all features. ```Shell ../sqlite/configure --enable-all ``` -------------------------------- ### SQLite CLI: Example - Registering a Hexadecimal Conversion Function Source: https://sqlite.org/cli.html/tclsqlite An example demonstrating the use of the `db function` method to create a new SQL function named 'hex'. This function converts its numeric argument into a hexadecimal encoded string, showcasing a practical application of custom SQL functions. ```TCL db function hex {format 0x%X} ``` -------------------------------- ### Compile SQLite on Unix-like Systems Source: https://sqlite.org/cli.html/src/attachdownload/doc/doc/doc/doc/doc/lemon Provides a step-by-step example of compiling SQLite on Unix-like systems. It includes commands to install necessary build tools, unpack the source, create a build directory, run the configure script, and build various SQLite components like `sqlite3`, `sqlite3.c` (amalgamation), `sqldiff`, TCL extension, and test targets. ```Shell apt install gcc make tcl-dev ;# Make sure you have all the necessary build tools tar xzf sqlite.tar.gz ;# Unpack the source tree into "sqlite" mkdir bld ;# Build will occur in a sibling directory cd bld ;# Change to the build directory ../sqlite/configure ;# Run the configure script make sqlite3 ;# Builds the "sqlite3" command-line tool make sqlite3.c ;# Build the "amalgamation" source file make sqldiff ;# Builds the "sqldiff" command-line tool # Makefile targets below this point require tcl-dev make tclextension-install ;# Build and install the SQLite TCL extension make devtest ;# Run development tests make releasetest ;# Run full release tests make sqlite3_analyzer ;# Builds the "sqlite3_analyzer" tool ``` -------------------------------- ### Example althttpd -auth File: Realm, HTTP Redirect, and User Authentication Source: https://sqlite.org/cli.html/althttpd/hexdump This '-auth' file example configures a specific realm for authentication, redirects HTTP requests to HTTPS, and defines a single user with a clear-text password for access. It's a typical setup for private directories requiring user login. ```Shell realm Access To All Fossil Repositories http-redirect user drh drh:xxxxxxxxxxxxxxxx ``` -------------------------------- ### Start althttpd for local website testing with browser tab Source: https://sqlite.org/cli.html/althttpd/doc/trunk/standalone-mode This command starts the althttpd server in stand-alone mode, listening on the first available port on the loopback address (127.0.0.1). It automatically opens a new browser tab pointing to the specified initial HTML page, such as 'index.html'. ```Shell althttpd --page index.html ```