doc updates

This commit is contained in:
Alex Garcia 2024-06-24 23:26:29 -07:00
parent 3a8ab9b489
commit dada170dc5
4 changed files with 54 additions and 13 deletions

View file

@ -57,10 +57,20 @@ If your vectors are from `numpy` arrays, the Python SQLite package allows you to
```python
import numpy as np
import sqlite3
import sqlite_vec
db = sqlite3.connect(":memory:")
db.enable_load_extension(True)
sqlite_vec.load(db)
db.enable_load_extension(False)
db.execute("CREATE VIRTUAL TABLE vec_demo(sample_embedding float[4])")
embedding = np.array([0.1, 0.2, 0.3, 0.4])
result = db.execute('select vec_length(?)', [embedding.astype(np.float32)]).fetchone()[0]
print(result) # 4
db.execute(
"INSERT INTO vec_demo(sample_embedding) VALUES (?)", [embedding.astype(np.float32)]
)
```
## Recipes