Documentation ¶
Overview ¶
Example (CreateDatabase) ¶
Example_createDatabase creates a SQL server and database, then creates a table and inserts a record.
var groupName = config.GenerateGroupName("DatabaseQueries") config.SetGroupName(groupName) serverName = strings.ToLower(serverName) ctx := context.Background() defer resources.Cleanup(ctx) _, err := resources.CreateGroup(ctx, config.GroupName()) if err != nil { util.LogAndPanic(err) } _, err = CreateServer(ctx, serverName, dbLogin, dbPassword) if err != nil { util.LogAndPanic(fmt.Errorf("cannot create sql server: %+v", err)) } util.PrintAndLog("sql server created") _, err = CreateDB(ctx, serverName, dbName) if err != nil { util.LogAndPanic(fmt.Errorf("cannot create sql database: %+v", err)) } util.PrintAndLog("database created") err = CreateFirewallRules(ctx, serverName) if err != nil { util.LogAndPanic(err) } util.PrintAndLog("database firewall rules set") err = testSQLDataplane(serverName, dbName, dbLogin, dbPassword) if err != nil { util.LogAndPanic(err) } util.PrintAndLog("database operations performed")
Output: sql server created database created database firewall rules set database operations performed
Index ¶
- func CreateDB(ctx context.Context, serverName, dbName string) (db sql.Database, err error)
- func CreateFirewallRules(ctx context.Context, serverName string) error
- func CreateServer(ctx context.Context, serverName, dbLogin, dbPassword string) (server sql.Server, err error)
- func CreateTable(db *sql.DB) error
- func DeleteDB(ctx context.Context, serverName, dbName string) (autorest.Response, error)
- func Insert(db *sql.DB) error
- func Open(server, database, username, password string) (*sql.DB, error)
- func Query(db *sql.DB) error
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateFirewallRules ¶
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
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.