Skip to main content

Nile Vector Store (PostgreSQL)

This integration makes it possible to use Nile - Postgres re-engineered for multi-tenant applications as a vector store in LlamaIndex.

What is Nile?

Nile is a Postgres database that enables all database operations per tenant including auto-scaling, branching, and backups, with full customer isolation.

Multi-tenant RAG applications are increasingly popular, since they provide security and privacy while using large language models.

However, managing the underlying Postgres database is not straightforward. DB-per-tenant is expensive and complex to manage, while shared-DB has security and privacy concerns, and also limits the scalability and performance of the RAG application. Nile re-engineered Postgres to deliver the best of all worlds - the isolation of DB-per-tenant, at the cost, efficiency and developer experience of a shared-DB.

Storing millions of vectors in a shared-DB can be slow and require significant resources to index and query. But if you store 1000 tenants in Nile's virtual tenant databases, each with 1000 vectors, this can be quite manageable. Especially since you can place larger tenants on their own compute, while smaller tenants can efficiently share compute resources and auto-scale as needed.

Getting Started with Nile

Start by signing up for Nile. Once you've signed up for Nile, you'll be promoted to create your first database. Go ahead and do so. You'll be redirected to the "Query Editor" page of your new database.

From there, click on "Home" (top icon on the left menu), click on "generate credentials" and copy the resulting connection string. You will need it in a sec.

Quickstart

Install the integration with:

pip install llama-index-vector-stores-nile

Use the connection string you generated earlier (at the "Getting started" step) to create a tenant-aware vector store.

:fire: NileVectorStore supports both tenant-aware vector stores, that isolates the documents for each tenant and a regular store which is typically used for shared data that all tenants can access. Below, we'll demonstrate the tenant-aware vector store.

# Replace with your connection string.
NILE_SERVICE_URL = "postgresql://nile:password@db.thenile.dev:5432/nile"

vector_store = NileVectorStore(
    service_url=NILEDB_SERVICE_URL,
    table_name="documents",
    tenant_aware=True,
    num_dimensions=1536,
)

Create an index from documents:

storage_context = StorageContext.from_defaults(vector_store=vector_store)
index = VectorStoreIndex.from_documents(
    documents_nexiv + documents_modamart,
    storage_context=storage_context,
    show_progress=True,
)

Or from existing embeddings:

index = VectorStoreIndex.from_vector_store(vector_store=vector_store)

and query each tenant's data with guaranteed isolation:

query_engine = index.as_query_engine(
    vector_store_kwargs={
        "tenant_id": str(tenant_id_modamart),
    },
)
response = query_engine.query("What action items do we need to follow up on?")

print(response)

See resources below for more information and examples.

Additional Resources

Release files for llama-index-vector-stores-nile 0.5.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-nile 0.5.0
File Size Uploaded
llama_index_vector_stores_nile-0.5.0.tar.gz 8.9 kB Details

Built distribution (wheel)

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

Total release size: 17.7 kB

Release files / llama_index_vector_stores_nile-0.5.0.tar.gz

Download URL llama_index_vector_stores_nile-0.5.0.tar.gz
Size 8.9 kB
Tags Source
SHA-256 checksum
How to use checksums
41816cbd691a76cdd5556f60d8afe70f5ebc1aa188a4122849ed71f9e5ccc3bf
BLAKE2b-256 checksum
How to use checksums
484b20abfaaa80ab390afb48b76b3fca2e0cec6a5b8133b0ec73800bfd8d36ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / llama_index_vector_stores_nile-0.5.0-py3-none-any.whl

Download URL llama_index_vector_stores_nile-0.5.0-py3-none-any.whl
Size 8.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
250aa9e39e172dfc59ca2ae947f622c246acf64a3f77181260813df5735229eb
BLAKE2b-256 checksum
How to use checksums
d32ae406a90b49815e11eb1f4629a9b5ab1ce4a686f61f15b39e1239a58cedda
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.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