From the course: LLM Foundations: Vector Databases for Caching and Retrieval Augmented Generation (RAG)

Create a connection

Having discussed several features about Milvus in the earlier chapter, let's exercise them in this chapter. We will create a collection, create indexes, populate data, and query the collection. In this video, we will start with creating a client connection to Milvus. The notebook for this chapter is in the file code_03_XX Milvus database operations. I have the notebook loaded up here. We first need to install prerequisite packages for these exercises. PyMilvus is the Python SDK for Milvus. OpenAI is the library we will use for OpenAI for both embeddings and for LLMs. Let's install these prerequisites now. We then move to the first step, connecting to a Milvus database. To connect to Milvus, we first need to add a connection to the list of connections. We specify a name for the collection as learn. Then we need to specify the host, port, username, and password for the connection. We have not set up any username or password yet, but this information is optional. We store the name of the connection in a variable for future reference. Then calling the connect method will create a connection to Milvus. Doing a list connections shows the list of connections from this client. Let's run this code now. Having opened a connection, we can now perform further operations using this connection.

Contents