Categorygithub.com/raff/rdsql
modulepackage
0.0.0-20240206051817-dd28172d8cd0
Repository: https://github.com/raff/rdsql.git
Documentation: pkg.go.dev

# README

Go Documentation Go Report Card

rdsql

A SQL client for AWS Aurora serverless using rds-data API

Package usage:

import "github.com/raff/rdsql"

awscfg := rdsql.GetAWSConfig(profile, debug)
client := rdsql.ClientWithOptions(awscfg, resourceArn, secretArn, dbName)

ch := make(chan os.Signal, 1)

tid, err := client.BeginTransaction(ch)

params := map[string]interface{} {
    "p1": "value1",
    "p2", 42,
}

res, dberr = client.ExecuteStatement("SELECT * FROM table WHERE col1 = :p1 AND col2 < :p2", params, tid, ch)

//
// you can also use:
//   client.EndTransaction(tid, dberr == nil, ch)
//

if dberr != nil {
    client.RollbackTransaction(tid, ch)
} else {
    client.CommitTransaction(tid, ch)
}

Command usage:

rdsql [options] [sql statement]
  -continue
        continue after timeout (for DDL statements) (default true)
  -csv
        print output as csv
  -database string
        database
  -debug
        enable debugging
  -elapsed
        print elapsed time
  -params string
        query parameters (comma separated list of name=value pair)
  -profile string
        AWS profile
  -resource string
        resource ARN
  -secret string
        resource secret
  -timeout duration
        request timeout (default 2m0s)
  -transaction
        wrap full session in a remote transaction
  -verbose
        log statements before execution

Environment variables:

RDS_RESOURCE (database cluster resource ARN, same as -resource)
RDS_SECRET (database resource secret ARN, same as -secret)
RDS_PROFILE (AWS account profile, same as -profile)

# Packages

No description provided by the author
No description provided by the author

# Functions

ClientWithOptions creates an instance of Client given a list of options.
ClientWithURI creates an instance of Client given an rdsql URI Format: rdsql:{profile};{resource};{secret};{database}.
No description provided by the author
GetAWSConfig return an aws.Config profile.
No description provided by the author
SQLReader returns a "list" of results from the specified queury.
SQLReaderLoop returns a "list" of results from the specified queury.
StringOrNil return nil for an empty string or aws.String.

# Variables

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

Client wraps *rdsdata.Client and client configuration (ResourceArn, SecretArn, etc...).

# Type aliases

ColumnMetadata is an alias for rdsdata types.ColumnMetadata.
Field is an alias for rdsdata types.Field.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Parameter is an alias for types.SqlParameter.