sql

package
v0.0.0-...-86c76a3 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2020 License: MIT Imports: 11 Imported by: 0

README


services: mssql platforms: go author: joshgav

Azure MSSQL Samples

This package demonstrates how to manage SQL databases and their data.

Contents

  • How to run all samples
  • Management
    • CreateServer
    • CreateDatabase
    • CreateFirewallRules
  • Data plane
    • Open
    • CreateTable
    • Insert
    • Query

How to run all samples

  1. Get this repo and all dependencies.
export PROJECT=github.com/Azure-Samples/azure-sdk-for-go-samples/compute
go get -u $PROJECT
cd ${GOPATH}/src/${PROJECT}
dep ensure
  1. Create an Azure service principal with the [Azure CLI][] command az ad sp create-for-rbac.
  2. Set the following environment variables based on output properties of this command. You can fill in these variables in .env.tpl in this directory and rename that to .env.
EnvVar Value
AZURE_CLIENT_ID service principal/application ID
AZURE_CLIENT_SECRET service principal/application secret
AZURE_TENANT_ID your tenant id
AZURE_SUBSCRIPTION_ID your subscription ID
AZURE_BASE_GROUP_NAME base resource group name
AZURE_LOCATION_DEFAULT location for all resources
  1. Run the sample. go test -v

More information

Please refer to Azure SDK for Go for more information.


This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Documentation

Overview

Package sql tests basic functionality for an existing mssql db

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDB

func CreateDB(ctx context.Context, serverName, dbName string) (db sql.Database, err error)

CreateDB creates a new SQL Database on a given server

func CreateFirewallRules

func CreateFirewallRules(ctx context.Context, serverName string) error

CreateFirewallRules creates new firewall rules for a given server

func CreateServer

func CreateServer(ctx context.Context, serverName, dbLogin, dbPassword string) (server sql.Server, err error)

CreateServer creates a new SQL Server

func CreateTable

func CreateTable(db *sql.DB) error

CreateTable creates an SQL table

func DeleteDB

func DeleteDB(ctx context.Context, serverName, dbName string) (autorest.Response, error)

DeleteDB deletes an existing database from a server

func Insert

func Insert(db *sql.DB) error

Insert adds a row to the SQL datablase

func Open

func Open(server, database, username, password string) (*sql.DB, error)

Open opens a connection to the SQL server

func PrintInfo

func PrintInfo()

PrintInfo logs information on SQL user agent and ARM client

func Query

func Query(db *sql.DB) error

Query queries the SQL database

Types

This section is empty.

Jump to

Keyboard shortcuts

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