Skip to content

Commit 89a0a70

Browse files
committed
Updated variable name [skip ci]
1 parent 22d9e98 commit 89a0a70

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -59,33 +59,33 @@ See a [full example](postmodern.lisp)
5959
Enable the extension
6060

6161
```lisp
62-
(dbi:do-sql *db* "CREATE EXTENSION IF NOT EXISTS vector")
62+
(dbi:do-sql *conn* "CREATE EXTENSION IF NOT EXISTS vector")
6363
```
6464

6565
Create a table
6666

6767
```lisp
68-
(dbi:do-sql *db* "CREATE TABLE items (id bigserial PRIMARY KEY, embedding vector(3))")
68+
(dbi:do-sql *conn* "CREATE TABLE items (id bigserial PRIMARY KEY, embedding vector(3))")
6969
```
7070

7171
Insert a vector
7272

7373
```lisp
74-
(dbi:do-sql *db* "INSERT INTO items (embedding) VALUES (?)" (list "[1,1,1]"))
74+
(dbi:do-sql *conn* "INSERT INTO items (embedding) VALUES (?)" (list "[1,1,1]"))
7575
```
7676

7777
Get the nearest neighbors
7878

7979
```lisp
80-
(dbi:fetch-all (dbi:execute (dbi:prepare *db* "SELECT * FROM items ORDER BY embedding <-> ? LIMIT 5") (list "[1,1,1]")))
80+
(dbi:fetch-all (dbi:execute (dbi:prepare *conn* "SELECT * FROM items ORDER BY embedding <-> ? LIMIT 5") (list "[1,1,1]")))
8181
```
8282

8383
Add an approximate index
8484

8585
```lisp
86-
(dbi:do-sql *db* "CREATE INDEX ON items USING ivfflat (embedding vector_l2_ops) WITH (lists = 100)")
86+
(dbi:do-sql *conn* "CREATE INDEX ON items USING ivfflat (embedding vector_l2_ops) WITH (lists = 100)")
8787
;; or
88-
(dbi:do-sql *db* "CREATE INDEX ON items USING hnsw (embedding vector_l2_ops)")
88+
(dbi:do-sql *conn* "CREATE INDEX ON items USING hnsw (embedding vector_l2_ops)")
8989
```
9090

9191
Use `vector_ip_ops` for inner product and `vector_cosine_ops` for cosine distance

cl-dbi.lisp

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
(ql:quickload :cl-dbi)
22

3-
(defvar *db*
3+
(defvar *conn*
44
(dbi:connect :postgres
55
:database-name "pgvector_lisp_test"))
66

7-
(dbi:do-sql *db* "CREATE EXTENSION IF NOT EXISTS vector")
7+
(dbi:do-sql *conn* "CREATE EXTENSION IF NOT EXISTS vector")
88

9-
(dbi:do-sql *db* "DROP TABLE IF EXISTS items")
9+
(dbi:do-sql *conn* "DROP TABLE IF EXISTS items")
1010

11-
(dbi:do-sql *db* "CREATE TABLE items (id bigserial PRIMARY KEY, embedding vector(3))")
11+
(dbi:do-sql *conn* "CREATE TABLE items (id bigserial PRIMARY KEY, embedding vector(3))")
1212

13-
(dbi:do-sql *db* "INSERT INTO items (embedding) VALUES (?)" (list "[1,1,1]"))
14-
(dbi:do-sql *db* "INSERT INTO items (embedding) VALUES (?)" (list "[2,2,2]"))
15-
(dbi:do-sql *db* "INSERT INTO items (embedding) VALUES (?)" (list "[1,1,2]"))
13+
(dbi:do-sql *conn* "INSERT INTO items (embedding) VALUES (?)" (list "[1,1,1]"))
14+
(dbi:do-sql *conn* "INSERT INTO items (embedding) VALUES (?)" (list "[2,2,2]"))
15+
(dbi:do-sql *conn* "INSERT INTO items (embedding) VALUES (?)" (list "[1,1,2]"))
1616

17-
(format t "~a~%" (dbi:fetch-all (dbi:execute (dbi:prepare *db* "SELECT * FROM items ORDER BY embedding <-> ? LIMIT 5") (list "[1,1,1]"))))
17+
(format t "~a~%" (dbi:fetch-all (dbi:execute (dbi:prepare *conn* "SELECT * FROM items ORDER BY embedding <-> ? LIMIT 5") (list "[1,1,1]"))))
1818

19-
(dbi:do-sql *db* "CREATE INDEX ON items USING hnsw (embedding vector_l2_ops)")
19+
(dbi:do-sql *conn* "CREATE INDEX ON items USING hnsw (embedding vector_l2_ops)")

0 commit comments

Comments
 (0)