Skip to main content

Drop-in pgvector wrapper with auto-provisioned Postgres. Zero config vector database.

Project description

pgvector-zerodb

Drop-in pgvector wrapper with auto-provisioned Postgres. Zero config vector database.

pip install pgvector-zerodb

Quick Start

from pgvector_zerodb import auto_connect

# Automatically provisions a free Postgres with pgvector if no DATABASE_URL is set
conn = auto_connect()

cur = conn.cursor()
cur.execute("CREATE TABLE items (id serial PRIMARY KEY, embedding vector(3))")
cur.execute("INSERT INTO items (embedding) VALUES ('[1,2,3]'), ('[4,5,6]')")
conn.commit()

cur.execute("SELECT * FROM items ORDER BY embedding <-> '[3,1,2]' LIMIT 5")
print(cur.fetchall())

That's it. No database setup, no config files, no cloud console.

How It Works

  1. You call auto_connect()
  2. It checks for DATABASE_URL or PGVECTOR_ZERODB_URL environment variable
  3. If neither exists, it provisions a free managed Postgres with pgvector via AINative
  4. Credentials are saved to ~/.ainative/pgvector-config.json for reuse
  5. Returns a standard psycopg2 connection with pgvector types registered

Use Your Own Postgres

If you already have a Postgres instance with pgvector:

export DATABASE_URL="postgresql://user:pass@host:5432/dbname"
from pgvector_zerodb import auto_connect
conn = auto_connect()  # Uses your DATABASE_URL, no provisioning

Same pgvector API

Everything from pgvector is re-exported. Existing code works unchanged:

from pgvector_zerodb import register_vector
import psycopg2

conn = psycopg2.connect("postgresql://...")
register_vector(conn)

With SQLAlchemy

from pgvector_zerodb import get_connection_string
from sqlalchemy import create_engine

engine = create_engine(get_connection_string())

With Django

Add to settings.py:

from pgvector_zerodb import get_connection_string
import dj_database_url

DATABASES = {"default": dj_database_url.parse(get_connection_string())}

Environment Variables

Variable Description
DATABASE_URL PostgreSQL connection string (highest priority)
PGVECTOR_ZERODB_URL Alternative env var for connection string
AINATIVE_API_KEY API key for provisioning (optional, enables higher limits)
ZERODB_API_KEY Alternative API key env var

Free Tier

The auto-provisioned Postgres includes:

  • pgvector extension pre-installed
  • 256 MB storage
  • Shared compute
  • No credit card required

Upgrade at ainative.studio for dedicated resources.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pgvector_zerodb-0.1.0.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pgvector_zerodb-0.1.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file pgvector_zerodb-0.1.0.tar.gz.

File metadata

  • Download URL: pgvector_zerodb-0.1.0.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for pgvector_zerodb-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4639147ca767ed3f89371a837b05ff2f862cd748d37364b0b501ee1285eeb86e
MD5 5c13b9271a55d61d84984dbf10d21ac0
BLAKE2b-256 4e0d74c38412649392f08fa7328991bc0d594d5bc95fb64f720306a658c3b949

See more details on using hashes here.

File details

Details for the file pgvector_zerodb-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pgvector_zerodb-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7daad4ebbdb96bc226462ec931c8d87edade89ce4daf8ae858f8e9546b2a67b0
MD5 b3b3bbbb183b674be7e38160e25f9299
BLAKE2b-256 10776bc03cfe2cbf6ef2185f341dccc1e7219a331757c26fb8b95f2c11173722

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page