{"id":23980,"library":"llama-index-storage-docstore-postgres","title":"llama-index-storage-docstore-postgres","description":"A LlamaIndex integration for storing document metadata (docstore) in PostgreSQL. Current version 0.5.0 requires Python >=3.10 and <4.0. Release cadence follows LlamaIndex's package updates.","status":"active","version":"0.5.0","language":"python","source_language":"en","source_url":"https://github.com/run-llama/llama_index/tree/main/llama-index-integrations/storage/llama-index-storage-docstore-postgres","tags":["llamaindex","postgres","docstore","storage","rag"],"install":[{"cmd":"pip install llama-index-storage-docstore-postgres","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Core LlamaIndex abstractions","package":"llama-index-core","optional":false},{"reason":"PostgreSQL async driver","package":"asyncpg","optional":false},{"reason":"ORM for PostgreSQL","package":"sqlalchemy","optional":false},{"reason":"PostgreSQL adapter","package":"psycopg2-binary","optional":true}],"imports":[{"note":"DocStore classes are in submodule, not directly in docstore","wrong":"from llama_index.storage.docstore import PostgresDocStore","symbol":"PostgresDocStore","correct":"from llama_index.storage.docstore.postgres import PostgresDocStore"}],"quickstart":{"code":"import os\nfrom llama_index.storage.docstore.postgres import PostgresDocStore\n\n# Set up connection (use environment variables for safety)\nconnection_string = os.environ.get(\n    \"POSTGRES_CONNECTION_STRING\",\n    \"postgresql+asyncpg://user:pass@localhost:5432/llamaindex\"\n)\n\ndocstore = PostgresDocStore.from_uri(\n    connection_string=connection_string,\n    table_name=\"docstore\",  # optional\n    schema_name=\"public\"     # optional\n)\nprint(\"PostgresDocStore created successfully\")","lang":"python","description":"Initialize a PostgreSQL-backed document store using a connection URI."},"warnings":[{"fix":"Migrate to `llama-index-storage-docstore-postgres` with new API or use `VectorStoreIndex` with PostgreSQL.","message":"The class `PostgresDocStore` is deprecated in favor of unified storage backends. Expect removal in future LlamaIndex versions.","severity":"deprecated","affected_versions":">=0.5.0"},{"fix":"Use async driver prefix: `postgresql+asyncpg://...` or `postgresql+psycopg://...` if using psycopg3 async.","message":"PostgresDocStore uses asyncpg by default, so you must use an async-compatible connection string (e.g., `postgresql+asyncpg://`). Sync drivers like `psycopg2` will fail.","severity":"gotcha","affected_versions":">=0.3.0"},{"fix":"Ensure the PostgreSQL user has CREATE TABLE privileges on the schema, or manually create the docstore table beforehand.","message":"Table and schema names must exist or be auto-created; auto-creation may fail in restricted environments.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Install the subpackage: `pip install llama-index-storage-docstore-postgres`","cause":"Wrong import path or missing subpackage installation.","error":"ModuleNotFoundError: No module named 'llama_index.storage.docstore.postgres'"},{"fix":"Upgrade asyncpg: `pip install --upgrade asyncpg`. Alternatively, configure PostgreSQL to accept md5 passwords.","cause":"PostgreSQL server requires SCRAM-SHA-256 but asyncpg might not support it in older versions.","error":"asyncpg.exceptions.InvalidAuthorizationSpecificationError: authentication method 10 not supported"},{"fix":"Use `postgresql+asyncpg://user:pass@host/db` or `postgresql+psycopg2://...` depending on driver.","cause":"Connection string missing driver prefix.","error":"sqlalchemy.exc.ArgumentError: Could not parse rfc1738 URL from string 'postgresql://...'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}