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 ¶
- func Register(aType *x.Type)
- 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 (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 (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 ¶
Types ¶
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.
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 { 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) 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