dynamosql

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2020 License: Apache-2.0 Imports: 14 Imported by: 1

README

dynamosql

DynamoDB SQL Driver

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Document

func Document(v interface{}) sql.Scanner

Document returns a sql.Scanner that can scan DynamoDB items into a struct or map using dynamodbattribute.UnmarshalMap (https://godoc.org/github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute). Refer to the library docs for usage.

func NewDBWithClient

func NewDBWithClient(ddb dynamodbiface.DynamoDBAPI) *sql.DB

NewDBWithClient returns a sql.DB backed by dynamosql using the given DynamoDB client.

func NewDBWithSession

func NewDBWithSession(sess *session.Session) *sql.DB

NewDBWithSession returns a sql.DB backed by dynamosql with a DynamoDB client constructed from the given Session.

Types

type Config

type Config struct {
	// If set, the driver will use this DynamoDB client. The Session param and the connection string will be ignored
	DynamoDB dynamodbiface.DynamoDBAPI
	// If set, and DynamoDB is not set, the driver will try to create a DynamoDB client using this session.
	Session *session.Session
	// If set, the wrapper collections []*dynamodb.AttributeValue, map[string]*dynamodb.AttributeValue will be mapped
	// unmarshaled into using the dynamodbattribute package into []interface{} and map[string]interface{}, respectively.
	AlwaysConvertCollectionsToGoType bool
}

Config provides optional settings to the DynamoDB driver.

type Driver

type Driver struct {
	// contains filtered or unexported fields
}

Driver is the DynamoDB SQL driver.

func New

func New(cfg Config) *Driver

New creates a Driver instance using a custom config. This may be easier to use than via sql.Open. A driver created using this function can be used to obtain a sql.DB like so

driver, err := New(Config{Session: sess}).OpenConnector("")
db := sql.OpenDB(driver)

func (*Driver) Open

func (d *Driver) Open(connStr string) (driver.Conn, error)

Open a connection using the connection string.

func (*Driver) OpenConnector

func (d *Driver) OpenConnector(connStr string) (driver.Connector, error)

OpenConnector initializes and returns a Connector. The db/sql package will call this exactly once per sql.Open() call. New connections to the database will use the returned Connector.

Directories

Path Synopsis
cmd
dynamosql Module
nolint: govet
nolint: govet
testing

Jump to

Keyboard shortcuts

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