Installation
SQL Anywhere can be used two ways. Pick the one that matches your goal:
- Embedded — link the
sqlanywhereRust crate into your application for an in-process database (optionally an embedded replica of a remote primary). - Server (
sqld) — run a standalone server that exposes SQLite over HTTP and WebSockets so remote clients can connect.
Both ship from the same project and stay byte-compatible with stock SQLite.
Embedded (Rust crate)
Add the crate to your project:
cargo add sqlanywhere
The default features include core, replication, remote, sync, and tls.
Building requires the Rust toolchain pinned in rust-toolchain.toml (currently
1.85.0); the encryption feature additionally needs cmake.
Open an in-memory (or on-disk) database:
use sqlanywhere::Builder;
#[tokio::main]
async fn main() {
let db = Builder::new_local(":memory:").build().await.unwrap();
let conn = db.connect().unwrap();
conn.execute("CREATE TABLE users (email TEXT)", ()).await.unwrap();
conn.execute("INSERT INTO users (email) VALUES ('alice@example.org')", ())
.await
.unwrap();
let mut rows = conn.query("SELECT email FROM users", ()).await.unwrap();
while let Some(row) = rows.next().await.unwrap() {
println!("{}", row.get_str(0).unwrap());
}
}
Point the same API at a remote primary to get an embedded replica that syncs in the background:
let db = Builder::new_local_replica("/tmp/local.db").build().await.unwrap();
db.sync().await.unwrap(); // pull the latest frames
let conn = db.connect().unwrap(); // reads are served locally
Server — prebuilt binary
The fastest way to run the sqld server is a prebuilt release binary. Download
the archive for your platform from the
releases page (or use
the download cards on the SQL Anywhere page):
| Platform | Archive |
|---|---|
| macOS (Apple Silicon) | sqld-vX.Y.Z-aarch64-apple-darwin.tar.gz |
| Linux (x86_64) | sqld-vX.Y.Z-x86_64-unknown-linux-gnu.tar.gz |
| Linux (ARM64) | sqld-vX.Y.Z-aarch64-unknown-linux-gnu.tar.gz |
Extract the archive and move the sqld binary onto your PATH:
# Example: macOS on Apple Silicon
curl -LO https://github.com/kwhorne/sql-anywhere/releases/latest/download/sqld-v0.2.0-aarch64-apple-darwin.tar.gz
tar -xzf sqld-v0.2.0-aarch64-apple-darwin.tar.gz
sudo mv sqld /usr/local/bin/
Run a standalone instance — by default sqld listens on 127.0.0.1:8080:
sqld
Then query it over HTTP:
curl -d '{"statements": ["SELECT 1"]}' http://127.0.0.1:8080
On macOS the binary is unsigned; if Gatekeeper blocks it, allow it under System Settings → Privacy & Security, or run
xattr -d com.apple.quarantine ./sqldbefore moving it.
Server — Docker
Prefer containers? Build the image and run it as described in the Docker guide. There is no published image to pull — you build your own from source.
Build from source
To compile the embedded library, the C library, or the sqld server yourself,
follow the Build & run guide. In short:
git clone https://github.com/kwhorne/sql-anywhere
cd sql-anywhere
cargo build --release # Rust workspace
cargo xtask build # SQLite-compatible C library and CLI tools
Verify
Check the interactive shell reports the expected version:
$ ./sqlanywhere
SQL Anywhere version 0.2.0 (based on SQLite version 3.43.0)
Enter ".help" for usage hints.
Next steps
- User guide — running primaries, replicas, and authentication
- HTTP API — talk to
sqldover HTTP - Build & run — every way to build and run the server