mirror of
https://github.com/turbot/steampipe.git
synced 2026-04-12 10:00:06 -04:00
* Provide feedback for failed prepared statements * Move error functions to error_helpers * Make maintenance client retriable
26 lines
604 B
Go
26 lines
604 B
Go
package db_local
|
|
|
|
import (
|
|
"context"
|
|
"github.com/jackc/pgconn"
|
|
|
|
"github.com/turbot/steampipe/pkg/constants"
|
|
)
|
|
|
|
func executeSqlAsRoot(ctx context.Context, statements ...string) ([]pgconn.CommandTag, error) {
|
|
var results []pgconn.CommandTag
|
|
rootClient, err := createLocalDbClient(ctx, &CreateDbOptions{Username: constants.DatabaseSuperUser})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rootClient.Close(ctx)
|
|
for _, statement := range statements {
|
|
result, err := rootClient.Exec(ctx, statement)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
results = append(results, result)
|
|
}
|
|
return results, nil
|
|
}
|