Documentation
¶
Index ¶
- type Config
- type Connection
- func (c *Connection) Begin() (driver.Tx, error)
- func (c *Connection) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error)
- func (c *Connection) Close() error
- func (c *Connection) IsValid() bool
- func (e *Connection) Lookup(SQL string) *exec.Execution
- func (c *Connection) Ping(ctx context.Context) error
- func (c *Connection) Prepare(SQL string) (driver.Stmt, error)
- func (c *Connection) PrepareContext(ctx context.Context, SQL string) (driver.Stmt, error)
- func (e *Connection) Put(execution *exec.Execution)
- func (c *Connection) ResetSession(ctx context.Context) error
- type Driver
- type Rows
- type Statement
- func (s *Statement) CheckNamedValue(named *driver.NamedValue) error
- func (s *Statement) Close() error
- func (s *Statement) Exec(args []driver.Value) (driver.Result, error)
- func (s *Statement) ExecContext(ctx context.Context, args []driver.NamedValue) (driver.Result, error)
- func (s *Statement) NumInput() int
- func (s *Statement) Query(args []driver.Value) (driver.Rows, error)
- func (s *Statement) QueryContext(ctx context.Context, args []driver.NamedValue) (driver.Rows, error)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
url.Values
CredURL string
CredKey string
CredID string
cred.Aws
ExecMaxCache int
}
Config represent Connection config
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection represent connection
func (*Connection) Begin ¶
func (c *Connection) Begin() (driver.Tx, error)
Begin starts and returns a new transaction.
func (*Connection) IsValid ¶
func (c *Connection) IsValid() bool
IsValid check is Connection is valid
func (*Connection) Prepare ¶
func (c *Connection) Prepare(SQL string) (driver.Stmt, error)
Prepare returns a prepared statement, bound to this Connection.
func (*Connection) PrepareContext ¶
PrepareContext returns a prepared statement, bound to this Connection.
Example ¶
type Publication struct {
ISBN string
Name string
IsTravel bool
IsFinance bool
}
db, err := sql.Open("dynamodb", "dynamodb://localhost:8000/us-west-1?cred=aws-e2e")
if err != nil {
log.Fatalln(err)
}
defer db.Close()
SQL := `SELECT ISBN, Name,
ARRAY_EXISTS(Categories, 'TRAVEL') AS IS_TRAVEL ,
ARRAY_EXISTS(Categories, 'FINANCE') AS IS_FINANCE
FROM Publication`
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
defer cancel()
stmt, err := db.PrepareContext(ctx, SQL)
if err != nil {
log.Fatalln(err)
}
rows, err := stmt.Query()
if err != nil {
log.Fatalln(err)
}
var records []*Publication
for rows.Next() {
record := &Publication{}
err = rows.Scan(&record.ISBN, &record.Name, &record.IsFinance, &record.IsTravel)
if err != nil {
log.Fatalln(err)
}
records = append(records, record)
}
data, _ := json.Marshal(records)
fmt.Printf("%s\n", data)
func (*Connection) ResetSession ¶
func (c *Connection) ResetSession(ctx context.Context) error
ResetSession resets session
type Driver ¶
type Driver struct{}
Driver is exported to make the driver directly accessible. In general the driver is used via the database/sql package.
type Rows ¶
type Rows struct {
// contains filtered or unexported fields
}
Rows represents rows driver
func (*Rows) ColumnTypeDatabaseTypeName ¶
ColumnTypeDatabaseTypeName returns column database type name
func (*Rows) ColumnTypeNullable ¶
ColumnTypeNullable returns if column is nullable
func (*Rows) ColumnTypeScanType ¶
ColumnTypeScanType returns column scan type
type Statement ¶
type Statement struct {
// contains filtered or unexported fields
}
Statement abstraction implements database/sql driver.Statement interface
func (*Statement) CheckNamedValue ¶
func (s *Statement) CheckNamedValue(named *driver.NamedValue) error
CheckNamedValue checks supported types (all for now)
func (*Statement) ExecContext ¶
func (s *Statement) ExecContext(ctx context.Context, args []driver.NamedValue) (driver.Result, error)
ExecContext executes statements
func (*Statement) QueryContext ¶
func (s *Statement) QueryContext(ctx context.Context, args []driver.NamedValue) (driver.Rows, error)
QueryContext runs query