go-athena: github.com/segmentio/go-athena Index | Files

package athena

import "github.com/segmentio/go-athena"

Index

Package Files

conn.go driver.go rows.go value.go

Constants

const (
    // TimestampLayout is the Go time layout string for an Athena `timestamp`.
    TimestampLayout             = "2006-01-02 15:04:05.999"
    TimestampWithTimeZoneLayout = "2006-01-02 15:04:05.999 MST"
    DateLayout                  = "2006-01-02"
)

func Open Uses

func Open(cfg Config) (*sql.DB, error)

Open is a more robust version of `db.Open`, as it accepts a raw aws.Session. This is useful if you have a complex AWS session since the driver doesn't currently attempt to serialize all options into a string.

type Config Uses

type Config struct {
    Session        *session.Session
    Database       string
    OutputLocation string

    PollFrequency time.Duration
}

Config is the input to Open().

type Driver Uses

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

Driver is a sql.Driver. It's intended for db/sql.Open().

func NewDriver Uses

func NewDriver(cfg *Config) *Driver

NewDriver allows you to register your own driver with `sql.Register`. It's useful for more complex use cases. Read more in PR #3. https://github.com/segmentio/go-athena/pull/3

Generally, sql.Open() or athena.Open() should suffice.

func (*Driver) Open Uses

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

Open should be used via `db/sql.Open("athena", "<params>")`. The following parameters are supported in URI query format (k=v&k2=v2&...)

- `db` (required) This is the Athena database name. In the UI, this defaults to "default", but the driver requires it regardless.

- `output_location` (required) This is the S3 location Athena will dump query results in the format "s3://bucket/and/so/forth". In the AWS UI, this defaults to "s3://aws-athena-query-results-<ACCOUNTID>-<REGION>", but the driver requires it.

- `poll_frequency` (optional) Athena's API requires polling to retrieve query results. This is the frequency at which the driver will poll for results. It should be a time/Duration.String(). A completely arbitrary default of "5s" was chosen.

- `region` (optional) Override AWS region. Useful if it is not set with environment variable.

Credentials must be accessible via the SDK's Default Credential Provider Chain. For more advanced AWS credentials/session/config management, please supply a custom AWS session directly via `athena.Open()`.

Package athena imports 14 packages (graph). Updated 2018-12-09. Refresh now. Tools for package owners.