-
Notifications
You must be signed in to change notification settings - Fork 20
Connecting to Cottontail DB
Communication with Cottontail DB is facilitated by gRPC. By default, the gRPC endpoint runs on port 1865. The server provides four different services: one for data definition (DDL), one for data management (DML) one for executing queries (DQL) and one for transaction support (TXN).
To connect to Cottontail DB, you must first generate the model classes and stubs using the gRPC library of your preference based on the programming environment you use. The definitions are contained in the cottontaildb-client
subproject.
For Kotlin and Java, there is also a Maven dependency, which includes pre-built stubs and models as well as a simple client API:
<dependency>
<groupId>org.vitrivr</groupId>
<artifactId>cottontaildb-client</artifactId>
<version>[version]</version>
</dependency>
Once you have included that dependency, you can create a connection as follows (Kotlin code):
val channel = ManagedChannelBuilder.forAddress("127.0.0.1", 1865).usePlaintext().build()
val dqlService = CottonDQLGrpc.newBlockingStub(channel)
val ddlService = CottonDDLGrpc.newBlockingStub(channel)
val dmlService = CottonDMLGrpc.newBlockingStub(channel)
val client = SimpleClient(channel)
We recommend use of the SimpleClient
, which is (as the name implies) easier to use. You can find a dedicated repository with simple examples for Java and Kotlin here.
There is also a Python Client maintained here.
Using Cottontail DB
Compatibility