mirror of
https://github.com/asg017/sqlite-vec.git
synced 2026-04-25 00:36:56 +02:00
misc docs
This commit is contained in:
parent
b57a05e2e8
commit
4b140f7294
6 changed files with 113 additions and 24 deletions
|
|
@ -1,7 +1,21 @@
|
|||
# Using `sqlite-vec` in Go
|
||||
|
||||
There are two ways you can embed `sqlite-vec` into Go applications: a CGO option
|
||||
for libraries like
|
||||
[`github.com/mattn/go-sqlite3`](https://github.com/mattn/go-sqlite3), or a
|
||||
WASM-based option with
|
||||
[`github.com/ncruces/go-sqlite3`](https://github.com/ncruces/go-sqlite3).
|
||||
|
||||
## Option 1: CGO
|
||||
|
||||
```bash
|
||||
go get -u github.com/asg017/sqlite-vec/bindings/go/cgo
|
||||
```
|
||||
|
||||
## Option 2: WASM based with `ncruces/go-sqlite3`
|
||||
|
||||
```
|
||||
go
|
||||
```
|
||||
|
||||
## Working with vectors in Go
|
||||
|
|
|
|||
|
|
@ -1,7 +1,33 @@
|
|||
# Using `sqlite-vec` in Rust
|
||||
|
||||
You can embed `sqlite-vec` into your Rust projects using the official
|
||||
[`sqlite-vec` crate](https://crates.io/crates/sqlite-vec).
|
||||
|
||||
```bash
|
||||
cargo add sqlite-vec
|
||||
```
|
||||
|
||||
The crate embeds the `sqlite-vec` C source code, and uses the
|
||||
[`cc` crate](https://crates.io/crates/sqlite-vec) to compile and statically link
|
||||
`sqlite-vec` at build-time.
|
||||
|
||||
The `sqlite-vec` crate exposes a single function `sqlite3_vec_init`, which is
|
||||
the C entrypoint for the SQLite extension. You can "register" with your Rust
|
||||
SQLite library's `sqlite3_auto_extension()` function. Here's an example with
|
||||
`rusqlite`:
|
||||
|
||||
```rs
|
||||
use sqlite_vec::sqlite3_vec_init;
|
||||
use rusqlite::{ffi::sqlite3_auto_extension};
|
||||
|
||||
fn main() {
|
||||
unsafe {
|
||||
sqlite3_auto_extension(Some(std::mem::transmute(sqlite3_vec_init as *const ())));
|
||||
}
|
||||
// future database connection will now automatically include sqlite-vec functions!
|
||||
}
|
||||
```
|
||||
|
||||
A full [`sqlite-vec` Rust demo](#TODO) is also available.
|
||||
|
||||
## Working with vectors in Rust
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue