Sign inSign up

azaddjan/pgvector

By azaddjan

•Updated almost 2 years ago

Postgres + PgVector

Image
Machine learning & AI
Data science
Databases & storage
0

1.1K

azaddjan/pgvector repository overview

⁠Overview: Using pgvector with Docker

This guide provides step-by-step instructions to run a Docker container with PostgreSQL and the pgvector extension. It includes commands to verify the extension, create a table, insert data, and perform queries.

⁠Steps to Run and Test
  1. Run the Docker Container:

    docker run --name pgvector-test -e POSTGRES_PASSWORD=postgres -d azaddjan/pgvector:v0.8.0-postgres17
    

    This command starts a PostgreSQL container with the pgvector extension pre-installed.

  2. Connect to the PostgreSQL Instance:

    docker exec -it pgvector-test psql -U postgres
    

    This connects you to the PostgreSQL instance using the psql CLI tool.

  3. Verify the pgvector Extension: Run the following SQL command to check if the vector extension is available:

    SELECT * FROM pg_available_extensions WHERE name = 'vector';
    
  4. Create a Table with a Vector Column: Create a table with a column to store vectors:

    CREATE TABLE items (id serial primary key, embedding vector(3));
    
  5. Insert Data into the Table: Insert a vector into the table:

    INSERT INTO items (embedding) VALUES ('[1, 2, 3]');
    
  6. Query Data from the Table: Retrieve the data from the table:

    SELECT * FROM items;
    
  7. Exit the PostgreSQL CLI: Use the following command to exit:

    \q
    
  8. Stop and Remove the Docker Container: Stop the container:

    docker stop pgvector-test
    

    Remove the container:

    docker rm pgvector-test
    
⁠Summary

This guide demonstrates how to set up and test the pgvector extension in a PostgreSQL database running in a Docker container. It covers essential operations such as verifying the extension, creating tables, inserting data, and performing queries. Once done, the container can be stopped and removed to free up resources.

Tag summary

Content type

Image

Digest

sha256:0713a7d9a…

Size

595.6 MB

Last updated

almost 2 years ago

docker pull azaddjan/pgvector