rockset

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

README

Go SQL driver for Rockset

This go module is a SQL driver for the Rockset database.

It currently only support the base SQL types

  • int64 using rockset.Int64
  • float64
  • bool
  • []byte
  • string
  • time.Time using rockset.Time

Usage

To use this driver you need a Rockset organization, and create an API key.

	db, err := sql.Open("rockset", "rockset://")
	// check error

    rows, err := db.QueryContext(ctx, "...")
	// check error

    for rows.Next() {
        err = rows.Scan(&var1, &var2)
        // check error
    }

Documentation

Overview

Package rockset provides a go driver for the Rockset database

Something about the package.

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	ErrNotImplemented   = errors.New("not implemented")
	ErrConnectionString = errors.New("incorrect connection string")
)
View Source
var ErrUnsupportedConversion = errors.New("unsupported conversion")

Functions

func ParseConnStr

func ParseConnStr(s string) (key string, server string, err error)

ParseConnStr extracts apikey and apiserver from a connection string like rockset://apikey@apiserver

Types

type Conn

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

func (*Conn) Begin

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

Begin is not supported.

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) Ping

func (c *Conn) Ping(ctx context.Context) error

func (*Conn) Prepare

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

Prepare is not supported.

func (*Conn) Query

func (c *Conn) Query(query string, args []driver.Value) (driver.Rows, error)

Query is used to execute an SQL query. Deprecated: use QueryContext instead

func (*Conn) QueryContext

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

QueryContext executes a query.

func (*Conn) Rollback

func (c *Conn) Rollback() error

Rollback is not supported.

type Driver

type Driver struct{}
Example

Example usage of the Rockset SQL driver

package main

import (
	"context"
	"database/sql"
	"log"

	_ "github.com/rockset/go-sql-driver"
)

func main() {
	ctx := context.TODO()

	// connect using environment variables ROCKSET_APIKEY and ROCKSET_APISERVER
	db, err := sql.Open("rockset", "rockset://")
	if err != nil {
		log.Fatal(err)
	}

	rows, err := db.QueryContext(ctx, `SELECT
    kind,
    count(kind) as total
FROM
    commons._events
group by
    kind
order by
    total DESC
`)
	if err != nil {
		log.Fatal(err)
	}

	var kind string
	var total int64
	for rows.Next() {
		err = rows.Scan(&kind, &total)
		if err != nil {
			log.Fatal(err)
		}
	}

}

func (*Driver) Open

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

Open connects to Rockset using a connection string of the format

  • rockset://
  • rockset://apikey@apiserver

The former connection string falls back to using the environment variables

  • ROCKSET_APIKEY
  • ROCKSET_APISERVER

type Int64

type Int64 int64

Int64 is used to handle int values, as the Rockset go client uses json.Unmarshal into an interface value, which makes all numbers become float64.

To unmarshal JSON into an interface value, Unmarshal stores one of these in the interface value:

  • bool, for JSON booleans
  • float64, for JSON numbers
  • string, for JSON strings
  • []interface{}, for JSON arrays
  • map[string]interface{}, for JSON objects
  • nil for JSON null

func (*Int64) Scan

func (i *Int64) Scan(a any) error

Scan converts the argument a into Int64

type Time

type Time struct{ time.Time }

Time is a time.Time that knows how to convert itself from a RFC3339 string.

func (*Time) Scan

func (t *Time) Scan(a any) error

Scan converts the argument a into Time

Jump to

Keyboard shortcuts

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