SingleStore DB

Connect with Go

You can get started with SingleStore (formerly MemSQL) and Go quickly. SingleStore is wire-compliant with MySQL, meaning connecting to SingleStore is as easy as connecting to a MySQL database.

The sections below describe how to connect your application. For a complete example, including samples of CRUD operations, refer to the following video and associated GitHub repo.

Prerequisites
  • A SingleStore cluster

  • Go

  • The mysql module for Go: go get github.com/go-sql-driver/mysql

Connection Details

To connect your Go application to your SingleStore cluster (SingleStore DB or SingleStore Managed Service) you'll need the following:

  • Host: the Admin endpoint (SingleStore Managed Service) or IP Address (SingleStore DB) for your cluster. You can find the Admin endpoint in the SingleStore Portal.

  • Port: default is 3306

  • User: admin (SingleStore Managed Service) or root (SingleStore DB).

  • Password

  • Database

Here is an example of a Go connection for a SingleStore Managed Service cluster:

func main() {

	HOSTNAME := "svc-12345678-1234-1234-1234-2d4b84322fd8-ddl.aws-region-1.svc.singlestore.com"
	PORT := "3306"
	USERNAME := "admin"
	PASSWORD := "<your admin password>"
	DATABASE := "acme"

	connection := USERNAME + ":" + PASSWORD + "@tcp(" + HOSTNAME + ":" + PORT + ")/" + DATABASE + "?parseTime=true"
	db, err := sql.Open("mysql", connection)
}
More Information

Using Stored Procedures: GitHub