sql

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: Apache-2.0 Imports: 33 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Example
package main

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

	_ "github.com/viant/structql/sql"
)

func main() {
	db, err := sql.Open("structql", "structql:///opt/local/testdata/")
	if err != nil {
		log.Fatal(err)
	}
	type Foo struct {
		ID   int
		Name string
	}
	_, err = db.Exec("REGISTER TYPE Foo AS ?", &Foo{})
	if err != nil {
		log.Fatal(err)
	}

	rows, err := db.QueryContext(context.Background(), "SELECT id,name FROM Foo WHERE id IN(?, ?)", 1, 3)
	if err != nil {
		log.Fatal(err)
	}
	var foos []*Foo
	for rows.Next() {
		var foo Foo
		err = rows.Scan(&foo.ID, &foo.Name)
		if err != nil {
			log.Fatal(err)
		}
		foos = append(foos, &foo)
	}
}

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(aType *x.Type)

Types

type Config

type Config struct {
	BaseURL string
	url.Values
}

Config represent Connection config

func ParseDSN

func ParseDSN(dsn string) (*Config, error)

ParseDSN parses the DSN string to a 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) BeginTx

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

BeginTx starts and returns a new transaction.

func (*Connection) Close

func (c *Connection) Close() error

Close closes Connection

func (*Connection) IsValid

func (c *Connection) IsValid() bool

IsValid check is Connection is valid

func (*Connection) Ping

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

Ping pings server

func (*Connection) Prepare

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

Prepare returns a prepared statement, bound to this Connection.

func (*Connection) PrepareContext

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

PrepareContext returns a prepared statement, bound to this Connection.

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.

func (Driver) Open

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

Open new Connection. See https://github.com/viant/structql#dsn-data-source-name for how the DSN string is formatted

type Rows

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

Rows represents rows driver

func (*Rows) Close

func (r *Rows) Close() error

Close closes rows

func (*Rows) ColumnTypeDatabaseTypeName

func (r *Rows) ColumnTypeDatabaseTypeName(index int) string

ColumnTypeDatabaseTypeName returns column database type name

func (*Rows) ColumnTypeNullable

func (r *Rows) ColumnTypeNullable(index int) (nullable, ok bool)

ColumnTypeNullable returns if column is nullable

func (*Rows) ColumnTypeScanType

func (r *Rows) ColumnTypeScanType(index int) reflect.Type

ColumnTypeScanType returns column scan type

func (*Rows) Columns

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

Columns returns query columns

func (*Rows) Next

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

Next moves to next row

type Statement

type Statement struct {
	BaseURL string
	SQL     string
	Kind    sqlparser.Kind
	// 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 globalTypes (all for now)

func (*Statement) Close

func (s *Statement) Close() error

Close closes statement

func (*Statement) Exec

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

Exec executes statements

func (*Statement) ExecContext

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

ExecContext executes statements

func (*Statement) NumInput

func (s *Statement) NumInput() int

NumInput returns numinput

func (*Statement) Query

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

Query runs query

func (*Statement) QueryContext

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

QueryContext runs query

Jump to

Keyboard shortcuts

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