azuremysql

package
v0.22.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 6, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package azuremysql provides connections to Azure Database for MySQL. See https://docs.microsoft.com/en-us/azure/mysql.

URLs

For mysql.Open, azuremysql registers for the scheme "azuremysql". To customize the URL opener, or for more details on the URL format, see URLOpener.

See https://gocloud.dev/concepts/urls/ for background information.

Example
package main

import (
	"context"
	"log"

	"gocloud.dev/mysql"
	_ "gocloud.dev/mysql/azuremysql"
)

func main() {
	// PRAGMA: This example is used on gocloud.dev; PRAGMA comments adjust how it is shown and can be ignored.
	// PRAGMA: On gocloud.dev, add a blank import: _ "gocloud.dev/mysql/azuremysql"
	// PRAGMA: On gocloud.dev, hide lines until the next blank line.
	ctx := context.Background()

	// Replace this with your actual settings.
	db, err := mysql.Open(ctx,
		"azuremysql://user:password@example00.mysql.database.azure.com/testdb")
	if err != nil {
		log.Fatal(err)
	}
	defer db.Close()

	// Use database in your program.
	db.Exec("CREATE TABLE foo (bar INT);")
}
Output:

Index

Examples

Constants

View Source
const Scheme = "azuremysql"

Scheme is the URL scheme azuremysql registers its URLOpener under on mysql.DefaultMux.

Variables

This section is empty.

Functions

This section is empty.

Types

type CertFetcher

type CertFetcher = azuredb.CertFetcher

CertFetcher is a default CertPoolProvider that can fetch CA certificates from any publicly accessible URI or File.

type CertPoolProvider

type CertPoolProvider = azuredb.CertPoolProvider

A CertPoolProvider obtains a certificate pool that contains the Azure CA certificate.

type URLOpener added in v0.16.0

type URLOpener struct {
	// CertSource specifies how the opener will obtain the Azure Certificate
	// Authority. If nil, it will use the default *azuredb.CertFetcher.
	CertSource azuredb.CertPoolProvider
	// TraceOpts contains options for OpenCensus.
	TraceOpts []ocsql.TraceOption
}

URLOpener opens Azure MySQL URLs like "azuremysql://user:password@myinstance.mysql.database.azure.com/mydb".

func (*URLOpener) OpenMySQLURL added in v0.16.0

func (uo *URLOpener) OpenMySQLURL(ctx context.Context, u *url.URL) (*sql.DB, error)

OpenMySQLURL opens an encrypted connection to an Azure MySQL database.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL