Skip to main content

LlamaIndex VectorStore Integration for IBM Db2

For a detailed guide look at https://github.com/run-llama/llama_index/blob/main/docs/docs/examples/vector_stores/db2llamavs.ipynb

pip install llama-index-vector-stores-db2

A sample example

from typing import TYPE_CHECKING
import sys
from llama_index.core.schema import Document, TextNode
from llama_index.vector_stores.db2 import DB2LlamaVS, DistanceStrategy
from llama_index.vector_stores.db2 import base as db2llamavs

if TYPE_CHECKING:
    import ibm_db

"""
Create connection to Db2 database instance

The following sample code will show how to connect to Db2 Database. Besides the dependencies above, you will need a Db2 database instance (with version v12.1.2+, which has the vector datatype support) running.
"""

import ibm_db_dbi

database = ""
username = ""
password = ""

try:
    connection = ibm_db_dbi.connect(database, username, password)
    print("Connection successful!")
except Exception as e:
    print("Connection failed!", e)


"""
Create Db2 vector store
"""

vectorstore = DB2LlamaVS.from_documents(
    client=conn,
    docs=chunks_with_mdata,
    table_name="db2vs",
    distance_strategy=DistanceStrategy.DOT_PRODUCT,
)

"""
Perform Similarity search
"""

# Similarity search
query = VectorStoreQuery(query_embedding=[1.0, 1.0], similarity_top_k=3)
results = vectorstore.query(query=query)
print(f"\n\n\nSimilarity search results for vector store: {results}\n\n\n")

Release files for llama-index-vector-stores-db2 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llama-index-vector-stores-db2 0.1.0
File Size Uploaded
llama_index_vector_stores_db2-0.1.0.tar.gz 7.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for llama-index-vector-stores-db2 0.1.0
File Interpreter ABI Platform
llama_index_vector_stores_db2-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 14.7 kB

Release files / llama_index_vector_stores_db2-0.1.0.tar.gz

Download URL llama_index_vector_stores_db2-0.1.0.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
64a5c5300dd0cbc9110cb50d9c5d048758aeb44d856602d979fb18e66ce1a15c
BLAKE2b-256 checksum
How to use checksums
b4893a14a02b0f37d384a84d6e96f10c2eeb7836b83f7aa5b924c6b0b60e97a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.21

Release files / llama_index_vector_stores_db2-0.1.0-py3-none-any.whl

Download URL llama_index_vector_stores_db2-0.1.0-py3-none-any.whl
Size 7.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d9dffc65fc31c28de489b6ad9181a2bf62e8f0b77ab005e12ae58ef80c0c0690
BLAKE2b-256 checksum
How to use checksums
12d1d650c959629a805536f220aa8ac4b4664fa4e9de154bf588675ec962eabb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.21

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page