ioxsql

package
v2.0.0-beta.5 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package ioxsql is the compatibility layer from influxdbiox to database/sql.

A database/sql connection can be established through sql.Open. Two data source name formats are supported.

The complete influxdbiox.ClientConfig struct is supported as JSON:

dsn := `{
  "address": "localhost:8082",
  "tls_cert": "...",
  "tls_key": "..."
}`
db, err := sql.Open("influxdb-iox", dsn)

The influxdbiox.ClientConfig struct serializes to JSON with method ToJSONString:

config := &influxdbiox.ClientConfig{
  Address:               "localhost:8082",
  TLSInsecureSkipVerify: true,
}
dsn, err = config.ToJSONString()
db, err := sql.Open("influxdb-iox", dsn)

The host:port address format is simpler to type, but only sets the address field:

db, err := sql.Open("influxdb-iox", "localhost:8082")

Or a influxdbiox.ClientConfig can be used directly.

config := &influxdbiox.ClientConfig{
  Address:               "localhost:8082",
  TLSInsecureSkipVerify: true,
}
db := sql.OpenDB(ioxsql.NewConnector(config))

Index

Constants

View Source
const DriverName = "influxdb-iox"

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

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

func (*Connection) Begin

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

func (*Connection) Client

func (c *Connection) Client() *influxdbiox.Client

Client returns the instance of *influxdbiox.Client backing this Connection. This is useful for sql.Conn.Raw():

conn, err := db.Conn(context.Background())
err = conn.Raw(func(driverConn interface{}) error {
  // This client object has type *influxdbiox.Client
  client := driverConn.(*ioxsql.Connection).Client()
  ...
  return nil
})

func (*Connection) Close

func (c *Connection) Close() error

func (*Connection) IsValid

func (c *Connection) IsValid() bool

func (*Connection) Ping

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

func (*Connection) Prepare

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

func (*Connection) PrepareContext

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

func (*Connection) ResetSession

func (c *Connection) ResetSession(ctx context.Context) error

type Connector

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

func NewConnector

func NewConnector(config *influxdbiox.ClientConfig) *Connector

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{}

func (*Driver) Open

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

func (*Driver) OpenConnector

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

Jump to

Keyboard shortcuts

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