gotds

package module
v0.0.0-...-135f7b3 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2014 License: MPL-2.0 Imports: 15 Imported by: 0

README

go-tds

An experimental pure-go TDS-driver. With it you should be able to connect to Microsoft SQL Servers (2000, 2005, 2008, 2012 and up). When it's done, that is. Sybase will not be supported.

Needless to say, this is NOT ready for production. Most SELECT statements will fail at this time.

For now it's just a collection of random code that I use to get to know the TDS protocol.

Documentation

Overview

go-tds is an experimental pure-go TDS-driver. With it you should be able to connect to Microsoft SQL Servers (2000, 2005, 2008, 2012 and up). It is not functional yet.

Index

Constants

View Source
const (
	TDS71  = 0x01000071
	TDS72  = 0x02000972
	TDS73  = 0x03000B73
	TDS73a = 0x03000a73 //Doesn't support NBCROW and Sparse Column sets
	TDS74  = 0x04000074
)
View Source
const (
	VERSION    pl_option_token = 0x00
	ENCRYPTION pl_option_token = 0x01
	INSTOPT                    = 0x02
	THREADID                   = 0x03
	MARS                       = 0x04
	TRACEID                    = 0x05
	TERMINATOR                 = 0xFF
)
View Source
const (
	// Fixed-length:
	// 0-length:
	NULLTYPE columnType = 0x1F // Null
	// 1-length:
	INT1TYPE columnType = 0x30 // TinyInt
	BITTYPE  columnType = 0x32 // Bit
	// 2-length:
	INT2TYPE columnType = 0x34 // SmallInt
	// 4-length:
	INT4TYPE     columnType = 0x38 // Int
	DATETIM4TYPE columnType = 0x3A // SmallDateTime
	FLT4TYPE     columnType = 0x3B // Real
	MONEY4TYPE   columnType = 0x7A // SmallMoney
	// 8-length:
	MONEYTYPE    columnType = 0x3C // Money
	DATETIMETYPE columnType = 0x3D // DateTime
	FLT8TYPE     columnType = 0x3E // Float
	INT8TYPE     columnType = 0x7F // BigInt

	//Variable USHORT (uint16)-length bytes:
	BIGVARBINTYPE columnType = 0xA5
	BIGVARCHRTYPE columnType = 0xA7
	BIGBINARYTYPE columnType = 0xAD
	BIGCHARTYPE   columnType = 0xAF
	NVARCHARTYPE  columnType = 0xE7
	NCHARTYPE     columnType = 0xEF
)

Variables

View Source
var (
	ErrInvalidData = errors.New("Invalid data found")
)

Functions

This section is empty.

Types

type Conn

type Conn struct {
	driver.Conn

	State    ConnectionState
	SubState SubState
	// contains filtered or unexported fields
}

func MakeConnection

func MakeConnection(cfg *config) (*Conn, error)

MakeConnection initiates a TCP connection with the specified configuration.

func MakeConnectionWithSocket

func MakeConnectionWithSocket(cfg *config, socket io.ReadWriteCloser) (*Conn, error)

MakeConnectionWithSocket initiates a connection using the specified ReadWriteCloser as an underlying socket. This allows for the TDS connections to take place over a protocol other than TCP, which the specs allow for.

func (*Conn) Close

func (c *Conn) Close() error

Immediately closes the socket.

func (*Conn) Exec

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

func (*Conn) Prepare

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

func (*Conn) Query

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

type ConnectionState

type ConnectionState int
const (
	Initial ConnectionState = iota
	PreLogin
	Login
	PostLogin
	Error
	Disconnected
)

type Driver

type Driver struct {
}

func (*Driver) Open

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

type Rows

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

func (Rows) Close

func (r Rows) Close() error

func (Rows) Columns

func (r Rows) Columns() []string

func (Rows) Next

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

type SQLError

type SQLError struct {
	//The error number (numbers less than 20001 are reserved by Microsoft SQL Server).
	Number int32
	// The error state, used as a modifier to the error number.
	State byte
	// Class a.k.a. severity determines the severity of the error.
	// Values below 10 indicate informational messages
	Class byte
	// The error message itself
	Text string
	// The name of the server
	Server string
	// The name of the procedure that caused the error
	Procedure string
	// The line-number at which the error occured. 1-based
	// 0 means not applicable.
	Line int32
}

func (SQLError) Error

func (e SQLError) Error() string

type Stmt

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

Stmt is a shim at the moment until I implement proper parameter handling

func (Stmt) Close

func (s Stmt) Close() error

func (Stmt) Exec

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

func (Stmt) NumInput

func (s Stmt) NumInput() int

func (Stmt) Query

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

type SubState

type SubState int
const (
	Ready SubState = iota
	RequestSent
	ParsingResponse
	NotificationSent
)

type Tx

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

Directories

Path Synopsis
Package utf16 implements encoding and decoding of UTF-16 sequences.
Package utf16 implements encoding and decoding of UTF-16 sequences.

Jump to

Keyboard shortcuts

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