Skip to content
33 changes: 15 additions & 18 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,25 @@ Our **[Colab notebook](https://colab.research.google.com/drive/1BND1nYHDg9DLsw5b

**USE AT YOUR OWN RISK:** The extension makes fundamental changes to the database storage layer. While designed to preserve ACID transaction safety, it's young and unlikely to have zero bugs. This project is not associated with the SQLite developers.

## SQLite ≥ 3.31.0 required
## SQLite requirements

**To use the Genomics Extension you might first need to upgrade SQLite itself.** The host program must link [SQLite version 3.31.0 (2020-01-22)](https://www.sqlite.org/releaselog/3_31_0.html) or newer. In your shell, `sqlite3 --version` displays the version installed with your OS, which is probably what your programs use; if in doubt, cause a program to report the result of `SELECT sqlite_version()`.
The SQLite library linked into your application must be at least version 3.31.0 (2020 vintage) and support [loadable extensions](https://www.sqlite.org/loadext.html). Check the version with `SELECT sqlite_version()` in your program.

If this is too old, then upgrade SQLite3 using your preferred binary package manager (e.g. apt, yum, conda, brew), if possible. Otherwise, modify your program's linking step or runtime environment to cause it to use an up-to-date version, for example by setting rpath or `LD_LIBRARY_PATH` to the location of an up-to-date shared library file. Resources:
The **macOS** default SQLite unfortunately disables extension loading. Homebrew and conda provide compatible SQLite packages; install one and configure your build system (if applicable) to use it.

* [How To Compile SQLite](https://www.sqlite.org/howtocompile.html)
* [DreamHost Knowledge Base - Installing a custom version of SQLite3](https://help.dreamhost.com/hc/en-us/articles/360028047592-Installing-a-custom-version-of-SQLite3)
* [Rpmfind: libsqlite3](https://rpmfind.net/linux/rpm2html/search.php?query=libsqlite3&submit=Search+...&system=&arch=)
* [Sqlite :: Anaconda Cloud](https://anaconda.org/anaconda/sqlite)
* Homebrew [formula/sqlite](https://formulae.brew.sh/formula/sqlite), [formula-linux/sqlite](https://formulae.brew.sh/formula-linux/sqlite)
* As a last resort for GNU/Linux, our [GitHub Releases](https://github.com/mlin/GenomicSQLite/releases) include a `libsqlite3.so.0` that should be compatible with modern (2015+) hosts.

You can always `SELECT sqlite_version()` to verify the upgrade in your program.
On other platforms, if SQLite is too old or lacks extension support, upgrade it with your package manager or see [How To Compile SQLite](https://www.sqlite.org/howtocompile.html). As a last resort for GNU/Linux, our [GitHub Releases](https://github.com/mlin/GenomicSQLite/releases) attach a widely-compatible `libsqlite3.so.0`.

## Installation

It's usually easiest to obtain the extension as a pre-compiled shared library (Linux .so or macOS .dylib), either installed with a package manager, or downloaded from [GitHub Releases](https://github.com/mlin/GenomicSQLite/releases).
It's usually easiest to obtain the extension as a pre-compiled shared library (GNU/Linux .so or macOS .dylib), either installed with a package manager, or downloaded from [GitHub Releases](https://github.com/mlin/GenomicSQLite/releases).

=== "Python"
``` bash
pip3 install [--user|--system] genomicsqlite
# -or-
conda install -c mlin genomicsqlite
```
Python's `sqlite3` module must support [loadable extensions](https://docs.python.org/3/library/sqlite3.html#sqlite3.Connection.enable_load_extension). Some macOS Python builds omit this support; Homebrew Python enables it. This is an interpreter build option, independent of the Python version.
On Ubuntu 24.04, the system Python (3.12.3) may emit a harmless `DeprecationWarning` about `?NNN` parameter binding. This CPython bug was fixed in 3.12.4.

The package loads a bundled shared library by default. To override the bundled file, set environment variable `LIBGENOMICSQLITE` to a filename.

Expand Down Expand Up @@ -81,11 +74,11 @@ It's usually easiest to obtain the extension as a pre-compiled shared library (L
}
```

Alternatively, download the JAR from [GitHub Releases](https://github.com/mlin/GenomicSQLite/releases) and place it in your classpath, along with [sqlite-jdbc](https://github.com/xerial/sqlite-jdbc)'s JAR which is also required. The package loads a bundled shared library by default. To override the bundled file, set environment variable `LIBGENOMICSQLITE` to a filename.
Alternatively, download the JAR from [GitHub Releases](https://github.com/mlin/GenomicSQLite/releases) and place it in your classpath, along with [sqlite-jdbc](https://github.com/xerial/sqlite-jdbc)'s JAR which is also required. The GenomicSQLite JAR loads a bundled shared library by default. To override the bundled file, set environment variable `LIBGENOMICSQLITE` to a filename. sqlite-jdbc similarly bundles a SQLite library.

To bundle GenomicSQLite and sqlite-jdbc inside an "Uber JAR" for your application, you may need to enable the [ServicesResourceTransformer for Maven Shade](https://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html#ServicesResourceTransformer) or [mergeServiceFiles() for Gradle Shadow](https://stackoverflow.com/questions/32887966/shadow-plugin-gradle-what-does-mergeservicefiles-do), to ensure the JDBC drivers will be registered automatically when the "Uber JAR" loads.

Recommendation: *also* install the Python package, which includes a useful command-line shell and smoke-test script.
Recommendation: *also* install the Python package, which includes a useful command-line shell and other tools.

=== "Rust"
Add to your project's `Cargo.toml`:
Expand All @@ -95,20 +88,24 @@ It's usually easiest to obtain the extension as a pre-compiled shared library (L
version = "^0"
```

Building with the crate will include a platform-appropriate shared library file within your compilation unit, to be extracted & loaded at runtime. To disable this, add `default-features = false` and at runtime, set environment variable `LIBGENOMICSQLITE` to a filename or place the library file somewhere it'll be found by `dlopen("libgenomicsqlite")`.
Building with the crate will include a platform-appropriate shared library file within your compilation unit, to be extracted & loaded at runtime. To disable this, add `default-features = false` to the dependencies entry and at runtime, set environment variable `LIBGENOMICSQLITE` to a filename or place the library file somewhere it'll be found by `dlopen("libgenomicsqlite")`.

To make `rusqlite` use an SQLite library other than the system's default, set `SQLITE3_LIB_DIR` and `SQLITE3_INCLUDE_DIR` to the `lib` and `include` directories where the library is installed.

Recommendation: *also* install the Python package, which includes a useful command-line shell and other tools.

=== "C/C++"
Download zip of shared library and `genomicsqlite.h` from [GitHub Releases](https://github.com/mlin/GenomicSQLite/releases). Build your program with them, and also ensure the dynamic linker will find the shared library at runtime, by either: (1) installing it in a system or user lib directory & refreshing cache, (2) setting `LD_LIBRARY_PATH` environment variable, (3) building with `-rpath`.

Recommendation: *also* install the Python package, which includes a useful command-line shell and smoke-test script.

GNU/Linux: to link the prebuilt `libgenomicsqlite.so` distributed from our GitHub Releases, you
may have to compile your source with `CXXFLAGS=-D_GLIBCXX_USE_CXX11_ABI=0`. This is because the
library is built against an old libstdc++ version to improve runtime compatibility. The
function of this flag is explained in the libstdc++ docs on
[Dual ABI](https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html). If you build
`libgenomicsqlite.so` from source, then the flag will not be needed.

Recommendation: *also* install the Python package, which includes a useful command-line shell and other tools.

See our [GitHub README](https://github.com/mlin/GenomicSQLite) for the source build procedure, if needed.

We welcome community contributions to the available language bindings; see the [Language Bindings Guide](bindings.md) if interested.
Expand Down
Loading