### Install and Run Python Quickstart Example Source: https://github.com/dolthub/doltlite/blob/master/README.md Installs the doltlite Python package and runs the quickstart example. This leverages the standard sqlite3 module with Doltlite preloaded. ```bash pip install doltlite python3 examples/quickstart.py ``` -------------------------------- ### Build and Run Go Quickstart Example Source: https://github.com/dolthub/doltlite/blob/master/README.md Builds and runs the Go quickstart example using mattn/go-sqlite3 with the libsqlite3 build tag. Ensure CGO flags point to the correct build directory. ```bash cd examples/go CGO_CFLAGS="-I../../build" CGO_LDFLAGS="../../build/libdoltlite.a -lz -lpthread" \ go build -tags libsqlite3 -o quickstart . ./quickstart ``` -------------------------------- ### Build and Run C Quickstart Example Source: https://github.com/dolthub/doltlite/blob/master/README.md Compiles and runs the C quickstart example. This demonstrates basic Doltlite functionality using the C API. ```bash cd build gcc -o quickstart ../examples/quickstart.c -I. libdoltlite.a -lpthread -lz ./quickstart ``` -------------------------------- ### Build SQLite Extension (Unix Example) Source: https://github.com/dolthub/doltlite/blob/master/autoconf/tea/README.txt Example of building the SQLite extension on a Unix system, including changing directory, configuring, testing, and installing. ```bash $ cd sqlite-*-tea $ ./configure --with-tcl=/path/to/tcl/install/root $ make test $ make install ``` -------------------------------- ### Manually Load Doltlite for Python Quickstart (Linux) Source: https://github.com/dolthub/doltlite/blob/master/README.md Manually preload libdoltlite.so for the Python quickstart example on Linux. This is an alternative to the pip package for local builds. ```bash cd build # Linux: LD_PRELOAD=./libdoltlite.so python3 ../examples/quickstart.py ``` -------------------------------- ### Install Tcl Source: https://github.com/dolthub/doltlite/blob/master/doc/tcl-extension-testing.md Install the configured Tcl build to the specified home directory. ```bash make install ``` -------------------------------- ### Build and Run Remote Server Source: https://github.com/dolthub/doltlite/blob/master/README.md Builds the standalone HTTP server for serving databases over the network and provides example commands to start it. The server supports push, fetch, pull, and clone. ```bash cd build make doltlite-remotesrv ./doltlite-remotesrv -p 8080 /path/to/databases/ # To bind to all interfaces (e.g. behind a TLS-terminating reverse proxy): ./doltlite-remotesrv -p 8080 --bind 0.0.0.0 /path/to/databases/ ``` -------------------------------- ### Installing and Verifying Autosetup Update Source: https://github.com/dolthub/doltlite/blob/master/autosetup/README.md Steps to install the updated autosetup into a project and verify the changes using 'fossil status'. ```bash $ /path/to/autosetup-checkout/autosetup --install . $ fossil status # show the modified files ``` -------------------------------- ### Example Hexdump Database Input Source: https://github.com/dolthub/doltlite/blob/master/tool/dbtotxt.md This example demonstrates how to embed a small test database directly into a script using the dbtotxt format. The input starts with metadata and is followed by page data, terminated by '| end'. ```sqlite .open --hexdb | size 8192 pagesize 4096 filename x9.db | page 1 offset 0 | 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3. | 16: 10 00 01 01 00 40 20 20 00 00 00 04 00 00 00 02 .....@ ........ | 32: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 04 ................ | 48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 ................ | 80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 ................ | 96: 00 2e 30 38 0d 00 00 00 01 0f c0 00 0f c0 00 00 ..08............ | 4032: 3e 01 06 17 11 11 01 69 74 61 62 6c 65 74 31 74 >......itablet1t | 4048: 31 02 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 1.CREATE TABLE t | 4064: 31 28 78 2c 79 20 44 45 46 41 55 4c 54 20 78 27 1(x,y DEFAULT x' | 4080: 66 66 27 2c 7a 20 44 45 46 41 55 4c 54 20 30 29 ff',z DEFAULT 0) | page 2 offset 4096 | 0: 0d 08 14 00 04 00 10 00 0e 05 0a 0f 04 15 00 10 ................ | 16: 88 02 03 05 90 04 0e 08 00 00 00 00 00 00 00 00 ................ | 1040: 00 00 00 00 ff 87 7c 02 05 8f 78 0e 08 00 00 00 ......|...x..... | 2064: 00 00 00 ff 0c 0a 01 fb 00 00 00 00 00 00 00 00 ................ | 2560: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 83 ................ | 2576: 78 01 05 87 70 0e 08 00 00 00 00 00 00 00 00 00 x...p........... | 3072: 00 00 00 00 00 00 00 00 00 ff 00 00 01 fb 00 00 ................ | 3584: 00 00 00 00 00 83 78 00 05 87 70 0e 08 00 00 00 ......x...p..... | 4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ff ................ end x9.db SELECT rowid FROM t1; PRAGMA integrity_check; ``` -------------------------------- ### Remote Server Setup for WASM Build Source: https://github.com/dolthub/doltlite/blob/master/ext/wasm/README.md Commands to install prerequisites and build the WASM module on the remote server. ```bash Remote: Install git, emsdk, and althttpd * Use a [version of althttpd][althttpd] from September 26, 2022 or newer. * Remote: Install the SQLite source tree. CD to ext/wasm * Remote: "`make`" to build WASM ``` -------------------------------- ### Install Prerequisites and Build SQLite Source: https://github.com/dolthub/doltlite/blob/master/AGENTS.md Installs necessary prerequisites on Debian/Ubuntu systems and then builds the SQLite CLI shell, its debugging variant, the amalgamation, and the test runner. ```bash apt install gcc make tcl-dev # prerequisites (Debian/Ubuntu) ./configure --dev # debug build make sqlite3 # CLI shell make sqlite3d # Debugging variant of the CLI shell make sqlite3.c # amalgamation (single-file distribution form) make testfixture # test runner binary (requires tcl-dev) make tclextension-install # install TCL extension before running tests ``` -------------------------------- ### Preferred Build: Install Tcl Extension (Unix) Source: https://github.com/dolthub/doltlite/blob/master/autoconf/tea/README.txt Installs the Tcl extension after it has been configured and built using the preferred method on Unix. ```bash make tclextension-install ``` -------------------------------- ### Install Emscripten SDK Source: https://github.com/dolthub/doltlite/blob/master/ext/wasm/README.md Steps to clone the Emscripten repository, install the latest SDK tools, and activate it for the current user on a Linux environment. ```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 ``` -------------------------------- ### Install TCL Extension Source: https://github.com/dolthub/doltlite/blob/master/doc/tcl-extension-testing.md Installs the SQLite TCL extension using nmake. ```batch nmake /f Makefile.msc tclextension-install ``` -------------------------------- ### Get Autosetup Reference Source: https://github.com/dolthub/doltlite/blob/master/autosetup/README.md Display the reference documentation for the Autosetup API. This command includes documentation from TCL files in the ./autosetup directory. ```bash $ ./configure --reference | less ``` -------------------------------- ### List Installed SQLite TCL Extensions Source: https://github.com/dolthub/doltlite/blob/master/doc/tcl-extension-testing.md Verify the correct installation of the TCL extension by listing it. ```bash make tclextension-list ``` -------------------------------- ### Compile SQLite with TCL Extensions and Tests on Windows Source: https://github.com/dolthub/doltlite/blob/master/doc/compile-for-windows.md Use these nmake commands to install TCL extensions and run tests. A TCL installation is required, and TCLDIR must be specified if not installed in C:\Tcl. ```bash nmake /f makefile.msc tclextension-install ``` ```bash nmake /f makefile.msc devtest ``` ```bash nmake /f makefile.msc releasetest ``` ```bash nmake /f makefile.msc sqlite3_analyzer.exe ``` -------------------------------- ### Configure SQLite with custom CFLAGS and defines Source: https://github.com/dolthub/doltlite/blob/master/autoconf/README.txt Example of passing both optimization flags and preprocessor defines to the configure script. ```bash $ CFLAGS="-Os -DSQLITE_OMIT_DEPRECATED" ./configure ``` -------------------------------- ### Preferred Build: Install Tcl Extension (Windows) Source: https://github.com/dolthub/doltlite/blob/master/autoconf/tea/README.txt Installs the Tcl extension on Windows using nmake, specifying the Tclsh command. ```bash nmake /f Makefile.msc tclextension-install TCLSH_CMD=$(TCLSH) ``` -------------------------------- ### Configure, Test, and Uninstall Teaish Build Source: https://github.com/dolthub/doltlite/blob/master/doc/tcl-extension-testing.md This command configures, tests, installs, and then uninstalls the teaish build. It is important to note that parallel builds (`-j#`) should not be used with this command as it can lead to race conditions during installation and uninstallation. ```bash ./configure --with-tcl=$TCLHOME make uninstall ``` -------------------------------- ### Configure TCL Installation Source: https://github.com/dolthub/doltlite/blob/master/doc/compile-for-unix.md Sets up a private installation of TCL development libraries in the $HOME/local directory. This is an optional step for building SQLite with TCL support. ```bash mkdir $HOME/local ``` ```bash ./configure --prefix=$HOME/local CFLAGS=-Os ``` ```bash make install ``` -------------------------------- ### Build with Visual C++ and specific defines Source: https://github.com/dolthub/doltlite/blob/master/autoconf/README.txt Example of passing preprocessor defines to the NMAKE build process on Windows using the OPTS macro. ```bash "OPTS=-DSQLITE_ENABLE_STAT4=1 -DSQLITE_OMIT_JSON=1" ``` -------------------------------- ### Serve WASM Demo Applications with make httpd Source: https://github.com/dolthub/doltlite/blob/master/ext/wasm/README.md A simpler command to start an HTTP server from the ext/wasm directory to serve the demo applications. ```bash # Or, more simply, from the ext/wasm dir: $ make httpd ``` -------------------------------- ### Install TCL 8.6 Source: https://github.com/dolthub/doltlite/blob/master/doc/tcl-extension-testing.md Installs the built TCL 8.6. This must be invoked separately from the 'release' target. ```batch nmake /f makefile.vc install ``` -------------------------------- ### Build and Test SQLite Extension (Unix) Source: https://github.com/dolthub/doltlite/blob/master/autoconf/tea/README.txt After configuration, build the SQLite extension and run tests to ensure correctness. Then, install the extension. ```bash make test make install ``` -------------------------------- ### Configure and Test Teaish Build Source: https://github.com/dolthub/doltlite/blob/master/doc/tcl-extension-testing.md This command configures, tests, and installs the teaish build of the extension. Ensure you are in the 'mkpkg_tmp/tea' directory and have set the TCLHOME environment variable. ```bash ./configure --with-tcl=$TCLHOME make test install ``` -------------------------------- ### Build DoltLite on Windows (MSYS2/MINGW64) Source: https://github.com/dolthub/doltlite/blob/master/README.md Build commands for Windows using MSYS2 and MINGW64. Includes package installation and build steps. ```bash pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-zlib make tcl mkdir -p build && cd build ../configure make doltlite.exe ./doltlite.exe :memory: ``` -------------------------------- ### Customizing Flag Defaults in Autosetup Source: https://github.com/dolthub/doltlite/blob/master/autosetup/README.md Example of how to define default values for flags within a custom Tcl script for autosetup. ```tcl proc sqlite-custom-flags {} { # If any existing --flags require different default values # then call: options-defaults { flag-name new-default-value ... } # ^^^ That will replace the default value but will not update # the --help text, which may lead to some confusion: # https://github.com/msteveb/autosetup/issues/77 return { {*} { # see below new-flag-name => {Help text} ... } }; } ``` -------------------------------- ### Build TCL for SQLite on Windows Source: https://github.com/dolthub/doltlite/blob/master/doc/compile-for-windows.md Use these nmake commands to build and install TCL development libraries on Windows. Ensure INSTALLDIR is set correctly. ```bash nmake /f makefile.vc INSTALLDIR=c:\Tcl release ``` ```bash nmake /f makefile.vc INSTALLDIR=c:\Tcl install ``` -------------------------------- ### Configure SQLite with Tcl Support Source: https://github.com/dolthub/doltlite/blob/master/doc/tcl-extension-testing.md Configure SQLite to use the installed Tcl, enabling all features. ```bash ./configure --with-tcl=$TCLHOME --all ``` -------------------------------- ### Emscripten-style Configuration Source: https://github.com/dolthub/doltlite/blob/master/ext/wasm/jaccwabyt/jaccwabyt.md Example configuration for StructBinderFactory using typical Emscripten WASM module properties. This setup provides the necessary heap, allocation, and deallocation functions. ```javascript { heap: Module?.asm?.memory || Module['wasmMemory'], //Or: // heap: ()=>Module['HEAP8'], alloc: (n)=>Module['_malloc'](n), dealloc: (m)=>Module['_free'](m) } ``` -------------------------------- ### Cloning and Updating Autosetup Repository Source: https://github.com/dolthub/doltlite/blob/master/autosetup/README.md Instructions for cloning the autosetup git repository or updating an existing local copy. ```bash $ git clone https://github.com/msteveb/autosetup $ cd autosetup # Or, if it's already checked out: $ git pull ``` -------------------------------- ### Remove Old Tcl Installation Source: https://github.com/dolthub/doltlite/blob/master/doc/tcl-extension-testing.md Ensure no stale Tcl installation exists by removing the target installation directory. ```bash rm -fr $TCLHOME ``` -------------------------------- ### Verify TCL Extension Installation Source: https://github.com/dolthub/doltlite/blob/master/doc/tcl-extension-testing.md Verifies the installation of the SQLite TCL extension. ```batch nmake /f Makefile.msc tclextension-verify ``` -------------------------------- ### Set TCL 9.0 Installation Directory Source: https://github.com/dolthub/doltlite/blob/master/doc/tcl-extension-testing.md Sets the environment variable for the TCL 9.0 installation directory. ```batch set INSTALLDIR=%TCLBUILD%\tcl90 ``` -------------------------------- ### Serve Demo Apps with althttpd Source: https://github.com/dolthub/doltlite/blob/master/ext/wasm/README-dist.txt A simple command to serve the demo applications using althttpd, enabling necessary features for WASM/JS builds. ```bash althttpd --enable-sab --page index.html ``` -------------------------------- ### Set TCL 8.6 Installation Directory Source: https://github.com/dolthub/doltlite/blob/master/doc/tcl-extension-testing.md Sets the environment variable for the TCL 8.6 installation directory. ```batch set INSTALLDIR=%TCLBUILD%\tcl86 ``` -------------------------------- ### Remove Test Tcl Installation Directory Source: https://github.com/dolthub/doltlite/blob/master/doc/tcl-extension-testing.md Clean up by removing the temporary Tcl installation directory after testing. ```bash rm -rf $TCLHOME ``` -------------------------------- ### Build WASM Components in ext/wasm Source: https://github.com/dolthub/doltlite/blob/master/ext/wasm/README.md Build the WASM components by navigating to the ext/wasm directory and running the make command. ```bash cd ext/wasm $ make ``` -------------------------------- ### Install Doltlite on macOS/Linux Source: https://github.com/dolthub/doltlite/blob/master/README.md Installs Doltlite using a curl and bash script for macOS (Apple Silicon) and Linux (x86_64 or arm64). ```bash sudo bash -c 'curl -fsSL https://github.com/dolthub/doltlite/releases/latest/download/install.sh | bash' ``` -------------------------------- ### Displaying testrunner.tcl Help Source: https://github.com/dolthub/doltlite/blob/master/doc/testrunner.md This command displays a summary of all available command-line options for the testrunner.tcl script. ```shell test/testrunner.tcl help ``` -------------------------------- ### Get Diff Statistics Between Branches Source: https://github.com/dolthub/doltlite/blob/master/doc/doltlite/demo.md Use `dolt_diff_stat` to get a summary of table differences (rows added, deleted, modified) between two branches. ```sql SELECT table_name, rows_added, rows_deleted, rows_modified FROM dolt_diff_stat('theory/butler', 'theory/ficus'); ``` -------------------------------- ### Run Release Tests with Pattern Matching Source: https://github.com/dolthub/doltlite/blob/master/doc/testrunner.md Patterns can be appended to commands like 'release' to match specific Tcl tests and fuzz tests. This example runs release tests and specifically targets tests matching 'rtree%'. ```bash test/testrunner.tcl release rtree% ``` -------------------------------- ### Initiate WASM Module Loading and Rendering Source: https://github.com/dolthub/doltlite/blob/master/ext/wasm/module-symbols.html Calls the sqlite3InitModule factory function with the defined module configuration and then calls renderIt once the module is loaded. ```javascript self.sqlite3InitModule(myModule).then(renderIt); })(); ``` -------------------------------- ### Specify Start Symbol Source: https://github.com/dolthub/doltlite/blob/master/doc/lemon.html Use %start_symbol followed by a non-terminal name to designate it as the grammar's start symbol, overriding the default first non-terminal. ```lemon %start_symbol prog ``` -------------------------------- ### Install Doltlite on Debian/Ubuntu Source: https://github.com/dolthub/doltlite/blob/master/README.md Installs Doltlite on Debian/Ubuntu systems using .deb packages. It fetches the latest version tag and downloads packages for the specified architecture. ```bash VER=$(curl -fsSL https://api.github.com/repos/dolthub/doltlite/releases/latest | jq -r .tag_name | sed 's/^v//') ARCH=amd64 # or arm64 BASE=https://github.com/dolthub/doltlite/releases/download/v${VER} wget ${BASE}/libdoltlite0_${VER}_${ARCH}.deb ${BASE}/doltlite_${VER}_${ARCH}.deb sudo dpkg -i libdoltlite0_*.deb doltlite_*.deb ``` -------------------------------- ### Example of %type and %destructor directives Source: https://github.com/dolthub/doltlite/blob/master/doc/lemon.html This example demonstrates how to define a data type for a non-terminal and specify a destructor to free allocated memory, preventing memory leaks. ```lemon %type nt {void*} %destructor nt { free($$); } nt(A) ::= ID NUM. { A = malloc( 100 ); } ``` -------------------------------- ### Struct Description JSON Example Source: https://github.com/dolthub/doltlite/blob/master/ext/wasm/jaccwabyt/jaccwabyt.md Example of a JSON object describing a C struct, including its name, size, and member details like offset, size, and signature. ```json { "name": "MyStruct", "sizeof": 16, "members": { "member1": {"offset": 0,"sizeof": 4,"signature": "i"}, "member2": {"offset": 4,"sizeof": 4,"signature": "p"}, "member3": {"offset": 8,"sizeof": 8,"signature": "j"} } } ``` -------------------------------- ### Get Row and Cell Change Counts Between Refs Source: https://github.com/dolthub/doltlite/blob/master/README.md Use `dolt_diff_stat` to get high-level change counts between two references (commits, branches, tags). You can optionally narrow the scope to a specific table. ```sql -- Row- and cell-level change counts between two refs (commits, branches, tags) SELECT * FROM dolt_diff_stat('v1.0', 'HEAD'); SELECT * FROM dolt_diff_stat('v1.0', 'HEAD', 'users'); -- narrow to one table ``` -------------------------------- ### DoltLite Diff Stat Source: https://github.com/dolthub/doltlite/blob/master/doc/doltlite/demo.md Get a summary of differences between two references using `dolt_diff_stat`. ```sql SELECT * FROM dolt_diff_stat('ref1', 'ref2') ``` -------------------------------- ### Compile and Link C Program (Static) Source: https://github.com/dolthub/doltlite/blob/master/README.md Statically link your C program with libdoltlite for a single binary with no runtime dependencies. Ensure the include path and library path are correct. ```bash # Static link (recommended — single binary, no runtime deps) gcc -o myapp myapp.c -I/path/to/build libdoltlite.a -lpthread -lz ``` -------------------------------- ### Update Emscripten SDK Source: https://github.com/dolthub/doltlite/blob/master/ext/wasm/README.md Commands to update an existing Emscripten SDK installation to the latest version. ```bash $ git pull $ ./emsdk install latest $ ./emsdk activate latest ``` -------------------------------- ### Initialize WASMFS with OPFS Source: https://github.com/dolthub/doltlite/blob/master/ext/wasm/speedtest1.html Initializes WASMFS with OPFS if available. Returns the mount directory or an empty string if not supported or initialization fails. This function is memoized. ```javascript const wasmfsDir = function f(wasmUtil){ if(undefined !== f._) return f._; const pdir = '/persistent'; if( !self.FileSystemHandle || !self.FileSystemDirectoryHandle || !self.FileSystemFileHandle){ return f._ = ""; } try{ if(0===wasmUtil.xCallWrapped( 'sqlite3_wasm_init_wasmfs', 'i32', ['string'], pdir )){ return f._ = pdir; }else{ return f._ = ""; } }catch(e){ // sqlite3_wasm_init_wasmfs() is not available return f._ = ""; } }; wasmfsDir._ = undefined; ``` -------------------------------- ### Verify SQLite TCL Extension Version Source: https://github.com/dolthub/doltlite/blob/master/doc/tcl-extension-testing.md Confirm that the installed TCL extension is of the correct version. ```bash make tclextension-verify ``` -------------------------------- ### Attach and Query SQLite Database Source: https://github.com/dolthub/doltlite/blob/master/README.md Demonstrates how to attach a standard SQLite database, query its tables using an alias, and detach it when finished. ```sql -- Attach a standard SQLite database ATTACH DATABASE '/path/to/events.sqlite' AS ops; -- Query it (prefix table names with the alias) SELECT * FROM ops.events WHERE type='click'; -- Main db tables need no prefix SELECT * FROM threads; -- Detach when done DETACH DATABASE ops; ``` -------------------------------- ### Build SQLite DLL with FTS and other extensions Source: https://github.com/dolthub/doltlite/blob/master/doc/compile-for-windows.md This command builds the deliverable sqlite3.dll and sqlite3.def files, enabling various extensions like FTS3/4/5, R-Tree, JSON1, and more. It works for both 32-bit and 64-bit builds. ```makefile nmake /f Makefile.msc sqlite3.dll USE_NATIVE_LIBPATHS=1 "OPTS=-DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_FTS4=1 -DSQLITE_ENABLE_FTS5=1 -DSQLITE_ENABLE_RTREE=1 -DSQLITE_ENABLE_JSON1=1 -DSQLITE_ENABLE_GEOPOLY=1 -DSQLITE_ENABLE_SESSION=1 -DSQLITE_ENABLE_PREUPDATE_HOOK=1 -DSQLITE_ENABLE_SERIALIZE=1 -DSQLITE_ENABLE_MATH_FUNCTIONS=1" ``` -------------------------------- ### Serve WASM Module Remotely Source: https://github.com/dolthub/doltlite/blob/master/ext/wasm/README.md Command to start the althttpd server with SharedArrayBuffer enabled on the remote machine. ```bash althttpd --enable-sab --port 8080 --popup ``` -------------------------------- ### Advanced struct instantiation with options Source: https://github.com/dolthub/doltlite/blob/master/ext/wasm/jaccwabyt/jaccwabyt.md Create a struct instance with advanced options including wrapping a pointer, taking ownership, zeroing on dispose, and allocating extra bytes. ```javascript const x = new MyStruct({ wrap: ptr, takeOwnership: bool, zeroOnDispose: bool , extraBytes: int }); ``` -------------------------------- ### C Struct Definition Source: https://github.com/dolthub/doltlite/blob/master/ext/wasm/jaccwabyt/jaccwabyt.md Example C struct definition for 'Foo' with integer, pointer, and 64-bit integer members. ```c // C-side: struct Foo { int member1; void * member2; int64_t member3; }; ``` -------------------------------- ### Initialize and Run SQLTester Worker Source: https://github.com/dolthub/doltlite/blob/master/ext/wasm/SQLTester/index.html Sets up a Web Worker to run SQLTester tests, handles messages from the worker, and initiates test execution. Includes logging and error handling for worker loading. ```javascript (async function(){ const W = new Worker('SQLTester.run.mjs',{ type: 'module' }); const wPost = (type,payload)=>W.postMessage({type,payload}); const mapToString = (v)=>{ switch(typeof v){ case 'string': return v; case 'number': case 'boolean': case 'undefined': case 'bigint': return ''+v; default: break; } if(null===v) return 'null'; if(v instanceof Error){ v = { message: v.message, stack: v.stack, errorClass: v.name }; } return JSON.stringify(v,undefined,2); }; const normalizeArgs = (args)=>args.map(mapToString); const logTarget = document.querySelector('#test-output'); const logClass = function(cssClass,...args){ const ln = document.createElement('div'); if(cssClass){ for(const c of (Array.isArray(cssClass) ? cssClass : [cssClass])){ ln.classList.add(c); } } ln.append(document.createTextNode(normalizeArgs(args).join(' '))); logTarget.append(ln); }; { const cbReverse = document.querySelector('#cb-log-reverse'); const cbReverseKey = 'SQLTester:cb-log-reverse'; const cbReverseIt = ()=>{ logTarget.classList[cbReverse.checked ? 'add' : 'remove']('reverse'); }; cbReverse.addEventListener('change', cbReverseIt, true); cbReverseIt(); } const btnRun = document.querySelector('#btn-run-tests'); const runTests = ()=>{ btnRun.setAttribute('disabled','disabled'); wPost('run-tests'); logTarget.innerText = 'Running tests...'; } btnRun.addEventListener('click', runTests); const log2 = function f(...args){ logClass('', ...args); return f; }; const log = function f(...args){ logClass('','index.html:',...args); return f; }; const timerId = setTimeout( ()=>{ logClass('error',"The SQLTester module is taking an unusually ", "long time to load. More information may be available", "in the dev console."); }, 3000 /* assuming localhost */ ); W.onmessage = function({data}){ switch(data.type){ case 'stdout': log2(data.payload.message); break; case 'tests-end': btnRun.removeAttribute('disabled'); delete data.payload.nTest; log("test results:",data.payload); break; case 'is-ready': clearTimeout(timerId); runTests(); break; default: log("unhandled onmessage",data); break; } }; })(); ``` -------------------------------- ### Hello World SQLite3 Database Connection Source: https://github.com/dolthub/doltlite/blob/master/ext/jni/README.md Demonstrates opening an in-memory SQLite3 database using the JNI binding. Ensure databases are always closed using sqlite3_close_v2() after use, and all active statements are finalized. ```java import org.sqlite.jni.*; import static org.sqlite.jni.CApi.*; ... final sqlite3 db = sqlite3_open(":memory:"); try { final int rc = sqlite3_errcode(db); if( 0 != rc ){ if( null != db ){ System.out.print("Error opening db: "+sqlite3_errmsg(db)); }else{ System.out.print("Error opening db: rc="+rc); } ... handle error ... } // ... else use the db ... }finally{ // ALWAYS close databases using sqlite3_close() or sqlite3_close_v2() // when done with them. All of their active statement handles must // first have been passed to sqlite3_finalize(). sqlite3_close_v2(db); } ``` -------------------------------- ### Configure SQLite Build Source: https://github.com/dolthub/doltlite/blob/master/doc/compile-for-unix.md Configures the SQLite build process, enabling all features and specifying the path to the Tcl shell if TCL support is desired. Run './configure --help' for a full list of options. ```bash ./configure --enable-all --with-tclsh=$HOME/local/bin/tclsh9.0 ``` -------------------------------- ### Configure SQLite Build with Script Source: https://github.com/dolthub/doltlite/blob/master/autosetup/README.md Defines all configure flags for known build modes, executes a provided script for build-mode-specific configuration, and then runs common finalization steps. ```shell sqlite-configure BUILD-NAME {script} ```