UltipaDocs
Try Playground
  • Introduction
    • Installation
    • Connection
      • Overview and Request Configuration
      • UQL Execution
      • GQL Execution
      • Graph
      • Schema and Property
      • Data Insertion
      • Query Acceleration
      • HDC Graph and Algorithm
      • Data Export
      • Process and Job
      • Access Control
    • Result Processing
    • Driver Data Classes
    • Installation
    • Connection
      • Overview and Request Configuration
      • UQL Execution
      • GQL Execution
      • Graph
      • Schema and Property
      • Data Insertion
      • Query Acceleration
      • HDC Graph and Algorithm
      • Data Export
      • Process and Job
      • Access Control
    • Result Processing
    • Driver Data Classes
    • Quick Start
    • Connect to Database
    • Query the Database
      • Graph
      • Schema and Property
      • Data Insertion
      • Query Acceleration
      • HDC Graph and Algorithm
      • Data Export
      • Process and Job
      • Access Control
    • Process Query Results
    • Data Structures
    • Quick Start
    • Connect to Database
    • Query the Database
      • Graph
      • Schema and Property
      • Data Insertion
      • Query Acceleration
      • HDC Graph and Algorithm
      • Data Export
      • Process and Job
      • Access Control
    • Process Query Results
    • Data Structures
    • Installation
    • Connection
    • Request Configuration
    • UQL Execution
    • GQL Execution
    • Graphset Management
    • Schema and Property Management
    • Data Insertion and Deletion
    • Query Acceleration
    • Algorithm Management
    • Downloads and Exports
    • Process and Task Management
    • Access Management
    • Server Statistics
    • Result Processing
    • Types Mapping Ultipa and C#
  • RESTful API
  1. Docs
  2. /
  3. Ultipa Drivers
  4. /
  5. Go

Connect to Database

Once you have installed the driver and set up an Ultipa instance, you can connect your application to the database.

Create a Connection

Creates a connection by instantiating NewUltipaDriver() with UltipaConfig, which holds the configuration details required to connect to the database.

See more connection configuration options →

Go
package main

import (
	"log"

	"github.com/ultipa/ultipa-go-driver/v5/sdk"
	"github.com/ultipa/ultipa-go-driver/v5/sdk/configuration"
)

func main() {
	config := &configuration.UltipaConfig{
        // URI example: Hosts: []string{"xxxx.us-east-1.cloud.ultipa.com:60010"},
		Hosts:    []string{"10.xx.xx.xx:60010"},
		Username: "<username>",
		Password: "<password>",
	}

	driver, err := sdk.NewUltipaDriver(config)
	if err != nil {
		log.Fatalln("Failed to connect to Ultipa:", err)
	}

    // Tests the connection
	isSuccess, _ := driver.Test(nil)
	println("Connection succeeds:", isSuccess)
}
Output
Connection succeeds: true

Use Configuration File

This example demonstrates how to use the configuration file config.yml to establish a connection:

Go
package main

import (
	"log"

	"github.com/ultipa/ultipa-go-driver/v5/sdk"
	"github.com/ultipa/ultipa-go-driver/v5/sdk/configuration"
)

func main() {
	config, _ := configuration.LoadConfigFromYAML("./config.yml")

	driver, err := sdk.NewUltipaDriver(config)
	if err != nil {
		log.Fatalln("Failed to connect to Ultipa:", err)
	}

	// Tests the connection
	isSuccess, _ := driver.Test(nil)
	println("Connection succeeds:", isSuccess)
}
Output
Connection succeeds: true

Example of the config.yml file:

config.yml
# hosts: ["mqj4zouys.us-east-1.cloud.ultipa.com:60010"]
hosts: 
  - "10.xx.xx.xx:60010"
  - "10.xx.xx.xx:60010"
  - "10.xx.xx.xx:60010"
username: "<username>"
password: "<password>"
default_graph: "miniCircle"
crt: 
max_recv_size: 

See more connection configuration options →

Connection Configuration

UltipaConfig or a configuration file can include the following fields:

Field
Type
Default
Description
Hosts[]string/Required. A comma-separated list of database server IPs or URLs. The protocol is automatically identified, do not include https:// or http:// as a prefix in the URL.
Usernamestring/Required. Username of the host authentication.
Passwordstring/Required. Password of the host authentication.
DefaultGraphstring/Name of the graph to use by default in the database.
Crt[]byte/The file path of the SSL certificate used for secure connections.
PasswordEncryptstringMD5Password encryption method of the driver. Supports MD5, LDAP and NOTHING.
Timeoutint32MaximumRequest timeout threshold (in seconds).
Heartbeatint0The heartbeat interval (in milliseconds), used to keep the connection alive. Set to 0 to disable.
MaxRecvSizeint32The maximum size (in MB) of the received data.