├── .github └── workflows │ ├── build.yml │ ├── incubator.yml │ └── publish.yml ├── .gitignore ├── LICENSE ├── Makefile ├── README.md └── init ├── init.h ├── initshell.c └── initsqlite.c /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: 4 | push: 5 | branches: [main] 6 | paths: 7 | - .github/** 8 | - init/** 9 | - Makefile 10 | pull_request: 11 | branches: [main] 12 | workflow_dispatch: 13 | 14 | jobs: 15 | download-sources: 16 | name: Download and store sources 17 | runs-on: ubuntu-latest 18 | steps: 19 | - name: Checkout sources 20 | uses: actions/checkout@v4 21 | 22 | - name: Download external sources 23 | run: | 24 | make prepare-src 25 | make download-sqlite 26 | make download-sqlean 27 | 28 | - name: Store sources 29 | uses: actions/upload-artifact@v4 30 | with: 31 | name: sources 32 | path: | 33 | init 34 | src 35 | Makefile 36 | 37 | build-ubuntu: 38 | name: Build for Ubuntu 39 | runs-on: ubuntu-latest 40 | needs: download-sources 41 | permissions: 42 | contents: write 43 | steps: 44 | - name: Install dependencies 45 | run: sudo apt update && sudo apt install -y libreadline-dev 46 | 47 | - name: Download sources 48 | uses: actions/download-artifact@v4 49 | with: 50 | name: sources 51 | 52 | - name: Compile sources 53 | run: | 54 | make prepare-dist 55 | make compile-sqlite-linux 56 | make compile-sqlean-linux 57 | 58 | build-windows: 59 | name: Build for Windows 60 | runs-on: windows-latest 61 | needs: download-sources 62 | permissions: 63 | contents: write 64 | steps: 65 | - name: Download sources 66 | uses: actions/download-artifact@v4 67 | with: 68 | name: sources 69 | 70 | - name: Compile sources 71 | shell: bash 72 | run: | 73 | make prepare-dist 74 | make compile-sqlite-windows 75 | make compile-sqlean-windows 76 | 77 | build-macos: 78 | name: Build for macOS 79 | runs-on: macos-latest 80 | needs: download-sources 81 | permissions: 82 | contents: write 83 | steps: 84 | - name: Download sources 85 | uses: actions/download-artifact@v4 86 | with: 87 | name: sources 88 | 89 | - name: Compile sources 90 | run: | 91 | make prepare-dist 92 | make compile-sqlite-macos 93 | make compile-sqlean-macos 94 | -------------------------------------------------------------------------------- /.github/workflows/incubator.yml: -------------------------------------------------------------------------------- 1 | name: Incubator 2 | 3 | on: 4 | workflow_dispatch: 5 | 6 | jobs: 7 | download-sources: 8 | name: Download and store sources 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: Checkout sources 12 | uses: actions/checkout@v4 13 | 14 | - name: Download external sources 15 | run: | 16 | make prepare-src 17 | make download-sqlite 18 | make download-sqlean 19 | 20 | - name: Store sources 21 | uses: actions/upload-artifact@v4 22 | with: 23 | name: sources 24 | path: | 25 | init 26 | src 27 | Makefile 28 | 29 | build-ubuntu: 30 | name: Build for Ubuntu 31 | runs-on: ubuntu-latest 32 | needs: download-sources 33 | permissions: 34 | contents: write 35 | steps: 36 | - name: Download sources 37 | uses: actions/download-artifact@v4 38 | with: 39 | name: sources 40 | 41 | - name: Compile sources 42 | run: | 43 | make prepare-dist 44 | make compile-sqlite-linux 45 | make compile-sqlean-linux 46 | 47 | build-windows: 48 | name: Build for Windows 49 | runs-on: windows-latest 50 | needs: download-sources 51 | permissions: 52 | contents: write 53 | steps: 54 | - name: Download sources 55 | uses: actions/download-artifact@v4 56 | with: 57 | name: sources 58 | 59 | - name: Compile sources 60 | shell: bash 61 | run: | 62 | make prepare-dist 63 | make compile-sqlite-windows 64 | make compile-sqlean-windows 65 | 66 | build-macos: 67 | name: Build for macOS 68 | runs-on: macos-latest 69 | needs: download-sources 70 | permissions: 71 | contents: write 72 | steps: 73 | - name: Download sources 74 | uses: actions/download-artifact@v4 75 | with: 76 | name: sources 77 | 78 | - name: Compile sources 79 | run: | 80 | make prepare-dist 81 | make compile-sqlite-macos 82 | make compile-sqlean-macos 83 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: Publish 2 | 3 | on: 4 | push: 5 | tags: 6 | - "*" 7 | workflow_dispatch: 8 | 9 | jobs: 10 | download-sources: 11 | name: Download and store sources 12 | runs-on: ubuntu-latest 13 | steps: 14 | - name: Checkout sources 15 | uses: actions/checkout@v4 16 | 17 | - name: Download external sources 18 | run: | 19 | make prepare-src 20 | make download-sqlite 21 | make download-sqlean 22 | 23 | - name: Store sources 24 | uses: actions/upload-artifact@v4 25 | with: 26 | name: sources 27 | path: | 28 | init 29 | src 30 | Makefile 31 | 32 | build-ubuntu: 33 | name: Build for Ubuntu 34 | runs-on: ubuntu-latest 35 | needs: download-sources 36 | permissions: 37 | contents: write 38 | steps: 39 | - name: Install dependencies 40 | run: sudo apt update && sudo apt install -y libreadline-dev 41 | 42 | - name: Download sources 43 | uses: actions/download-artifact@v4 44 | with: 45 | name: sources 46 | 47 | - name: Compile sources 48 | run: | 49 | make prepare-dist 50 | make compile-sqlite-linux 51 | make compile-sqlean-linux 52 | 53 | - name: Upload binaries to release 54 | uses: svenstaro/upload-release-action@v2 55 | with: 56 | repo_token: ${{ secrets.GITHUB_TOKEN }} 57 | file: dist/* 58 | file_glob: true 59 | tag: ${{ github.ref }} 60 | 61 | build-windows: 62 | name: Build for Windows 63 | runs-on: windows-latest 64 | needs: download-sources 65 | permissions: 66 | contents: write 67 | steps: 68 | - name: Download sources 69 | uses: actions/download-artifact@v4 70 | with: 71 | name: sources 72 | 73 | - name: Compile sources 74 | shell: bash 75 | run: | 76 | make prepare-dist 77 | make compile-sqlite-windows 78 | make compile-sqlean-windows 79 | 80 | - name: Upload binaries to release 81 | uses: svenstaro/upload-release-action@v2 82 | with: 83 | repo_token: ${{ secrets.GITHUB_TOKEN }} 84 | file: dist/*.exe 85 | file_glob: true 86 | tag: ${{ github.ref }} 87 | 88 | build-macos: 89 | name: Build for macOS 90 | runs-on: macos-latest 91 | needs: download-sources 92 | permissions: 93 | contents: write 94 | steps: 95 | - name: Download sources 96 | uses: actions/download-artifact@v4 97 | with: 98 | name: sources 99 | 100 | - name: Compile sources 101 | run: | 102 | make prepare-dist 103 | make compile-sqlite-macos 104 | make compile-sqlean-macos 105 | 106 | - name: Upload binaries to release 107 | uses: svenstaro/upload-release-action@v2 108 | with: 109 | repo_token: ${{ secrets.GITHUB_TOKEN }} 110 | file: dist/*-macos 111 | file_glob: true 112 | tag: ${{ github.ref }} 113 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | dist -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Anton Zhiyanov 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 Anton Zhiyanov, MIT License 2 | # https://github.com/nalgeon/sqlite 3 | 4 | SQLITE_RELEASE_YEAR := 2025 5 | SQLITE_VERSION := 3490100 6 | SQLEAN_VERSION := 0.27.2 7 | 8 | SQLITE_OPT_WIN := -DSQLITE_ENABLE_DBPAGE_VTAB -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_GEOPOLY -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_MATH_FUNCTIONS -DSQLITE_ENABLE_OFFSET_SQL_FUNC -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_STAT4 -DSQLITE_ENABLE_STMTVTAB -DSQLITE_ENABLE_UNKNOWN_SQL_FUNCTION -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_THREADSAFE=0 -DSQLITE_USE_URI 9 | 10 | SQLITE_OPT := $(SQLITE_OPT_WIN) -DHAVE_READLINE -DSQLITE_HAVE_ZLIB 11 | 12 | SQLITE_SRC := src/shell.c src/sqlite3.c 13 | 14 | SQLEAN_INC := -include src/regexp/constants.h 15 | 16 | SQLEAN_OPT := -DSQLITE_EXTRA_INIT=core_init -DSQLEAN_VERSION='"$(SQLEAN_VERSION)"' 17 | 18 | SQLEAN_SRC_WIN := src/sqleanshell.c src/sqlean.c src/sqlite3-sqlean.c src/crypto/*.c src/define/*.c src/fileio/*.c src/fuzzy/*.c src/math/*.c src/regexp/*.c src/regexp/pcre2/*.c src/stats/*.c src/text/*.c src/text/*/*.c src/time/*.c src/unicode/*.c src/uuid/*.c src/vsv/*.c 19 | 20 | SQLEAN_SRC := $(SQLEAN_SRC_WIN) src/ipaddr/*.c 21 | 22 | LINK_LIB := -ldl -lz -lm -lreadline -lncurses 23 | 24 | prepare-src: 25 | mkdir -p src 26 | rm -rf src/* 27 | 28 | download-sqlite: 29 | curl -L https://github.com/sqlite/sqlite/raw/master/src/test_windirent.h --output src/test_windirent.h 30 | curl -L http://sqlite.org/$(SQLITE_RELEASE_YEAR)/sqlite-amalgamation-$(SQLITE_VERSION).zip --output sqlite.zip 31 | unzip sqlite.zip 32 | mv sqlite-amalgamation-$(SQLITE_VERSION)/* src 33 | rmdir sqlite-amalgamation-$(SQLITE_VERSION) 34 | 35 | download-sqlean: 36 | curl -L https://github.com/nalgeon/sqlean/archive/refs/tags/$(SQLEAN_VERSION).zip --output sqlean.zip 37 | unzip sqlean.zip 38 | mv sqlean-$(SQLEAN_VERSION)/src/* src 39 | cat src/sqlite3.c init/initsqlite.c > src/sqlean.c 40 | cat src/shell.c init/initshell.c > src/sqleanshell.c 41 | cp init/init.h src 42 | rm -rf sqlean-$(SQLEAN_VERSION) 43 | 44 | prepare-dist: 45 | mkdir -p dist 46 | rm -f dist/* 47 | 48 | compile-sqlite-linux: 49 | gcc -Os $(SQLITE_OPT) $(SQLITE_SRC) -o dist/sqlite3-ubuntu $(LINK_LIB) 50 | chmod +x dist/sqlite3-ubuntu 51 | 52 | compile-sqlite-windows: 53 | gcc -Os -Isrc $(SQLITE_OPT_WIN) $(SQLITE_SRC) -o dist/sqlite3.exe 54 | 55 | compile-sqlite-macos: 56 | gcc -Os $(SQLITE_OPT) $(SQLITE_SRC) -o dist/sqlite3-macos-x86 -target x86_64-apple-macos10.15 $(LINK_LIB) 57 | gcc -Os $(SQLITE_OPT) $(SQLITE_SRC) -o dist/sqlite3-macos-arm -target arm64-apple-macos11 $(LINK_LIB) 58 | lipo -create -output dist/sqlite3-macos dist/sqlite3-macos-x86 dist/sqlite3-macos-arm 59 | chmod +x dist/sqlite3-macos 60 | 61 | compile-sqlean-linux: 62 | gcc -O1 -Isrc $(SQLITE_OPT) $(SQLEAN_OPT) $(SQLEAN_INC) $(SQLEAN_SRC) -o dist/sqlean-ubuntu $(LINK_LIB) 63 | chmod +x dist/sqlean-ubuntu 64 | 65 | compile-sqlean-windows: 66 | gcc -O1 -Isrc $(SQLITE_OPT_WIN) $(SQLEAN_OPT) $(SQLEAN_INC) $(SQLEAN_SRC_WIN) -o dist/sqlean.exe 67 | 68 | compile-sqlean-macos: 69 | gcc -O1 -Isrc $(SQLITE_OPT) $(SQLEAN_OPT) $(SQLEAN_INC) $(SQLEAN_SRC) -o dist/sqlean-macos-x86 -target x86_64-apple-macos10.15 $(LINK_LIB) 70 | gcc -O1 -Isrc $(SQLITE_OPT) $(SQLEAN_OPT) $(SQLEAN_INC) $(SQLEAN_SRC) -o dist/sqlean-macos-arm -target arm64-apple-macos11 $(LINK_LIB) 71 | lipo -create -output dist/sqlean-macos dist/sqlean-macos-x86 dist/sqlean-macos-arm 72 | chmod +x dist/sqlean-macos 73 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SQLite / Sqlean builds 2 | 3 | This repo provides customized builds for [`sqlite`](https://sqlite.org) and [`sqlean`](https://github.com/nalgeon/sqlean) shells. 4 | 5 | ## SQLite 6 | 7 | Builds and publishes SQLite shell (aka command-line interface or CLI) for different Linux, Windows and macOS. 8 | 9 | The list of enabled features: 10 | 11 | - `SQLITE_ENABLE_DBPAGE_VTAB`. Enables the [sqlite_dbpage](https://sqlite.org/dbpage.html) virtual table. 12 | - `SQLITE_ENABLE_DBSTAT_VTAB`. Enables the [dbstat](https://sqlite.org/dbstat.html) virtual table. 13 | - `SQLITE_ENABLE_EXPLAIN_COMMENTS`. Makes [EXPLAIN](https://sqlite.org/lang_explain.html) output more readable. 14 | - `SQLITE_ENABLE_FTS4`. Enables [FTS3 and FTS4](https://sqlite.org/fts3.html) extensions. 15 | - `SQLITE_ENABLE_FTS5`. Enables the [FTS5](https://sqlite.org/fts5.html) extension. 16 | - `SQLITE_ENABLE_GEOPOLY`. Enables the [Geopoly](https://sqlite.org/geopoly.html) extension. 17 | - `SQLITE_ENABLE_JSON1`. Enables the [JSON1](https://sqlite.org/json1.html) extension. 18 | - `SQLITE_ENABLE_MATH_FUNCTIONS`. Enables [math functions](https://sqlite.org/lang_mathfunc.html). 19 | - `SQLITE_ENABLE_OFFSET_SQL_FUNC`. Enables the [sqlite_offset(x)](https://sqlite.org/lang_corefunc.html#sqlite_offset) function. 20 | - `SQLITE_ENABLE_RTREE`. Enables the [R\*Tree](https://sqlite.org/rtree.html) extension. 21 | - `SQLITE_ENABLE_STAT4`. Helps query planner to make better index choices. 22 | - `SQLITE_ENABLE_STMTVTAB`. Enables the [sqlite_stmt](https://sqlite.org/stmt.html) virtual table. 23 | - `SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION`. Ignores unknown functions in EXPLAIN, useful for debugging. 24 | - `SQLITE_HAVE_ZLIB`. Required for [SQL Archive](https://sqlite.org/sqlar.html) support. Not available on Windows. 25 | - `SQLITE_LIKE_DOESNT_MATCH_BLOBS`. Forces LIKE and GLOB to return FALSE for BLOBs. 26 | - `SQLITE_THREADSAFE=0`. Turns off support for multithreaded environment. 27 | - `SQLITE_USE_URI`. Enables [URI](https://sqlite.org/uri.html) connection strings. 28 | 29 | Latest release: [3.49.1](https://github.com/nalgeon/sqlite/releases/latest) 30 | 31 | ## Sqlean 32 | 33 | `sqlean` shell is SQLite shell bundled with a collection of [essential extensions](https://github.com/nalgeon/sqlean) ranging from regular expressions and math statistics to file I/O and dynamic SQL. 34 | 35 | ``` 36 | sqlean shell = 37 | ┌───────────────────────────┐ 38 | │ sqlite shell │ 39 | ├ + ────────────────────────┤ 40 | │ crypto ipaddr text │ 41 | │ define math time │ 42 | │ fileio regexp uuid │ 43 | │ fuzzy stats vsv │ 44 | └───────────────────────────┘ 45 | ``` 46 | 47 | Builds are available for every OS: 48 | 49 | - `sqlean.exe` - for Windows 50 | - `sqlean-ubuntu` - for Ubuntu (and other Debian-based distributions) 51 | - `sqlean-macos` - for macOS (supports both Intel and Apple processors) 52 | 53 | Latest release: [3.49.1](https://github.com/nalgeon/sqlite/releases/latest) (using Sqlean 0.27.2). 54 | 55 | **Note for macOS users**. macOS disables unsigned binaries and prevents the `sqlean` shell from running. To resolve this issue, remove the build from quarantine by running the following command in Terminal (replace `/path/to/folder` with an actual path to the folder containing the `sqlean-macos` binary): 56 | 57 | ``` 58 | chmod +x /path/to/folder/sqlean-macos 59 | xattr -d com.apple.quarantine /path/to/folder/sqlean-macos 60 | ``` 61 | 62 | And then run the shell: 63 | 64 | ``` 65 | $ /path/to/folder/sqlean-macos 66 | SQLite version 3.42.0 2023-05-16 12:36:15 67 | Enter ".help" for usage hints. 68 | Connected to a transient in-memory database. 69 | Use ".open FILENAME" to reopen on a persistent database. 70 | sqlean> █ 71 | ``` 72 | -------------------------------------------------------------------------------- /init/init.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 Anton Zhiyanov, MIT License 2 | // https://github.com/nalgeon/sqlite 3 | 4 | #ifndef INIT_H 5 | #define INIT_H 6 | 7 | #include 8 | 9 | #include "sqlite3ext.h" 10 | 11 | int sqlite3_sqlean_init(sqlite3* db, char** errmsg_ptr, const sqlite3_api_routines* api); 12 | void shell_sqlean_init(); 13 | 14 | #endif /* INIT_H */ 15 | -------------------------------------------------------------------------------- /init/initshell.c: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 Anton Zhiyanov, MIT License 2 | // https://github.com/nalgeon/sqlite 3 | 4 | void shell_sqlean_init() { 5 | sqlite3_snprintf(sizeof(mainPrompt), mainPrompt, "sqlean> "); 6 | } 7 | -------------------------------------------------------------------------------- /init/initsqlite.c: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 Anton Zhiyanov, MIT License 2 | // https://github.com/nalgeon/sqlite 3 | 4 | #include "init.h" 5 | 6 | int core_init(const char* dummy) { 7 | shell_sqlean_init(); 8 | return sqlite3_auto_extension((void*)sqlite3_sqlean_init); 9 | } 10 | --------------------------------------------------------------------------------