dapi

package module
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

README

dapi

dapi is a Go sql.Driver for the AWS RDS Data API

Motivation

I wanted to the productivity of using gorm combined with the utility of convenience of the RDS Data API. Looking around, I couldn't find anything that fit the bill and hence, dapi

QuickStart

dapi is intended to work as a standard golang sql.Driver and specifically as a driver usable by gorm

func main() {
    var (
        s           = session.Must(session.NewSession(aws.NewConfig()))
        api         = rdsdataservice.New(s)
        driver      = dapi.New(api)
        database    = "the database name"
        secretARN   = "secret arn holding database credentials"
        resourceARN = "resource arn"
        dsn         = fmt.Sprintf("secret=%v resource=%v database=%v", secretARN, resourceARN, database)
        dialect     = "mysql"
    )

	sql.Register(dialect, driver)
	db, err := gorm.Open(dialect, dsn)
    // at this point you can use gorm as you normally would
}

Maturity

This project is very new and should not be used for production. Your mileage may vary.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

Types

type Conn

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

func (*Conn) Begin

func (c *Conn) Begin() (driver.Tx, error)

func (*Conn) BeginTx

func (c *Conn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error)

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) ExecContext

func (c *Conn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error)

func (*Conn) Prepare

func (c *Conn) Prepare(query string) (driver.Stmt, error)

func (*Conn) PrepareContext

func (c *Conn) PrepareContext(ctx context.Context, query string) (driver.Stmt, error)

func (*Conn) QueryContext

func (c *Conn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error)

type Connector

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

func (*Connector) Connect

func (c *Connector) Connect(ctx context.Context) (driver.Conn, error)

func (*Connector) Driver

func (c *Connector) Driver() driver.Driver

type Driver

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

func (*Driver) Open

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

func (*Driver) OpenConnector

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

type Result

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

func (*Result) Close

func (r *Result) Close() error

func (*Result) Columns

func (r *Result) Columns() []string

func (*Result) LastInsertId

func (r *Result) LastInsertId() (int64, error)

func (*Result) Next

func (r *Result) Next(dest []driver.Value) error

func (*Result) RowsAffected

func (r *Result) RowsAffected() (int64, error)

type Stmt

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

func (*Stmt) Close

func (s *Stmt) Close() error

func (*Stmt) Exec

func (s *Stmt) Exec(args []driver.Value) (driver.Result, error)

func (*Stmt) ExecContext

func (s *Stmt) ExecContext(ctx context.Context, args []driver.NamedValue) (driver.Result, error)

func (*Stmt) NumInput

func (s *Stmt) NumInput() int

NumInput returns the number of placeholder parameters.

If NumInput returns >= 0, the sql package will sanity check argument counts from callers and return errors to the caller before the statement's Exec or Query methods are called.

NumInput may also return -1, if the driver doesn't know its number of placeholders. In that case, the sql package will not sanity check Exec or Query argument counts.

func (*Stmt) Query

func (s *Stmt) Query(args []driver.Value) (driver.Rows, error)

func (*Stmt) QueryContext

func (s *Stmt) QueryContext(ctx context.Context, args []driver.NamedValue) (driver.Rows, error)

type Tx

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

func (*Tx) Commit

func (t *Tx) Commit() error

func (*Tx) Rollback

func (t *Tx) Rollback() error

Jump to

Keyboard shortcuts

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