-
Hi, I wrote the following Python code based on the basic example doc, and getting an error. import sqlite3
import sqlite_vss
# https://alexgarcia.xyz/sqlite-vss/python.html
db = sqlite3.connect(":memory:")
db.enable_load_extension(True)
sqlite_vss.load(db)
db.enable_load_extension(False)
(version,) = db.execute("select vss_version()").fetchone()
print(version)
print(sqlite3.sqlite_version)
db.execute(
"""
create virtual table vss_demo using vss0(
a(2)
);
"""
)
db.execute(
"""
insert into vss_demo(rowid, a)
select
value ->> 0 as rowid,
value ->> 1 as a
from json_each('
[
[ 1, [1.0, 3.0] ],
[ 2, [3.0, 1.0] ],
[ 3, [-2.0, -2.0] ],
[ 4, [-4.0, 1.0] ]
]
');
"""
)
db.execute(
"""
select
rowid,
distance
from vss_demo
where vss_search(a, json('[2.0, 2.0]'))
limit 1;
"""
) The error I got:
Could you guide me what's wrong with this? It seems the Lines 1096 to 1101 in 6681374 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Those docs are still a work-in-progress, but the problem here canbe solved with: db.commit() after inserting into This is because all writes to Apologies for the confusion! Will be updating the docs (and will catch/handle that error since that isn't the best experience) Thanks for the detailed report! |
Beta Was this translation helpful? Give feedback.
Those docs are still a work-in-progress, but the problem here canbe solved with:
after inserting into
vss_demo
.This is because all writes to
vss0
tables don't appear until a transaction is complete, which you sometimes have to explicitly do in Python.Apologies for the confusion! Will be updating the docs (and will catch/handle that error since that isn't the best experience)
Thanks for the detailed report!