Compose Database-as-a-Service Help and Documentation

Everything you need to know about Compose, Hosted or Enterprise, is here in our help system. Whether you run one database for your businesses' sole application or six different databases to support an entire corporation, we've got the information you need.

Go and Compose for MySQL

Go has a generic interface for SQL databases and using it with the go-sql-driver will provide us with several options to connect to MySQL. The problem with the driver is that we cannot verify the self-signed certificate. The only TLS/SSL option we have with self-signed certificates is skip-verify, which is less than optimal.

To connect to MySQL using Go, first install the go-sql-driver package to your $GOPATH:

go get github.com/go-sql-driver/mysql

You can use the following code to connect to MySQL.

package main

import (  
    "database/sql"
    "log"
    "fmt"
    _ "github.com/go-sql-driver/mysql"
)

func main() {  
    db, err := sql.Open("mysql", "admin:[email protected](aws-us-east-1-portal.23.dblayer.com:15918)/compose?tls=skip-verify")
    if err != nil {
        log.Fatal(err)
    }
    defer db.Close()
    
    rows, err := db.Query("SHOW DATABASES")
    if err != nil {
        log.Fatal(err)
    }

    var dbNames string
    for rows.Next() {
        err := rows.Scan(&dbNames)
        if err != nil {
        log.Fatal(err)
        }
        fmt.Println(dbNames)
    }
}

Still Need Help?

If this article didn't solve things, summon a human and get some help!

Updated about a year ago

Go and Compose for MySQL


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.