CrateDB is a distributed and scalable SQL database for storing and analyzing massive amounts of data in near real-time, even with complex queries. It is PostgreSQL-compatible, based on Lucene, and inheriting from Elasticsearch.
Installation and Setup
Setup CrateDB
There are two ways to get started with CrateDB quickly. Alternatively, choose other CrateDB installation options.Start CrateDB on your local machine
Example: Run a single-node CrateDB instance with security disabled, using Docker or Podman. This is not recommended for production use.Deploy cluster on CrateDB Cloud
CrateDB Cloud is a managed CrateDB service. Sign up for a free trial.Install Client
Install the most recent version of the langchain-cratedb package and a few others that are needed for this tutorial.Documentation
For a more detailed walkthrough of the CrateDB wrapper, see using LangChain with CrateDB. See also all features of CrateDB to learn about other functionality provided by CrateDB.Features
The CrateDB adapter for LangChain provides APIs to use CrateDB as vector store, document loader, and storage for chat messages.Vector Store
Use the CrateDB vector store functionality aroundFLOAT_VECTOR and KNN_MATCH
for similarity search and other purposes. See also CrateDBVectorStore Tutorial.
Make sure you’ve configured a valid OpenAI API key.
Document Loader
Load load documents from a CrateDB database table, using the document loaderCrateDBLoader, which is based on SQLAlchemy. See also CrateDBLoader Tutorial.
To use the document loader in your applications:
Chat Message History
Use CrateDB as the storage for your chat messages. See also CrateDBChatMessageHistory Tutorial. To use the chat message history in your applications:Full Cache
The standard / full cache avoids invoking the LLM when the supplied prompt is exactly the same as one encountered already. See also CrateDBCache Example. To use the full cache in your applications:Semantic Cache
The semantic cache allows users to retrieve cached prompts based on semantic similarity between the user input and previously cached inputs. It also avoids invoking the LLM when not needed. See also CrateDBSemanticCache Example. To use the semantic cache in your applications:Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.