Documentation
¶
Overview ¶
Microsoft SQL Server (MS SQL Server) TDS Protocol database client.
For use with sql client interface:
github.com/kardianos/rdb
This driver doesn't use cgo or any c libraries and is self contained.
Supported Data Types
rdb. TypeNull TypeString :: Maps to nvarchar TypeAnsiString :: Maps to varchar TypeBinary :: Maps to varbinary TypeText TypeAnsiText TypeVarChar TypeAnsiVarChar TypeChar TypeAnsiChar TypeBool TypeInt8 TypeInt16 TypeInt32 TypeInt64 TypeFloat32 TypeFloat64 TypeDecimal TypeTDZ TypeTime TypeDate TypeTD :: Maps to DateTime2 tds. TypeOldTD :: Maps to DateTime
The following types support io.Writer for output fields, and io.Reader for input parameters:
TypeString TypeAnsiString TypeBinary TypeVarChar TypeAnsiVarChar
Transactions are not yet supported.
Out parameters are not yet supported.
Parameter names are not optional. They must be supplied.
Index ¶
- Constants
- type Bulk
- type Connection
- func (tds *Connection) Available() bool
- func (tds *Connection) Begin(ctx context.Context, iso rdb.IsolationLevel) error
- func (tds *Connection) Close()
- func (tds *Connection) Commit(ctx context.Context) error
- func (tds *Connection) ConnectionInfo() *rdb.ConnectionInfo
- func (tds *Connection) NextQuery(ctx context.Context) (err error)
- func (tds *Connection) NextResult(ctx context.Context) (more bool, err error)
- func (tds *Connection) Open(ctx context.Context, config *rdb.Config) (*ServerInfo, error)
- func (tds *Connection) Opened() time.Time
- func (tds *Connection) Prepare(*rdb.Command) (preparedStatementToken interface{}, err error)
- func (tds *Connection) Query(ctx context.Context, cmd *rdb.Command, params []rdb.Param, ...) error
- func (tds *Connection) Reset(c *rdb.Config) error
- func (tds *Connection) Rollback(savepoint string) error
- func (tds *Connection) SavePoint(ctx context.Context, name string) error
- func (tds *Connection) Scan(ctx context.Context) error
- func (tds *Connection) SetAvailable(available bool)
- func (tds *Connection) Status() rdb.DriverConnStatus
- func (tds *Connection) Unprepare(preparedStatementToken interface{}) (err error)
- type Driver
- type EncryptAvailable
- type InputToolong
- type MessageReader
- func (mr *MessageReader) Close() error
- func (r *MessageReader) Fetch(ctx context.Context, n int) (ret []byte, err error)
- func (r *MessageReader) FetchAll(ctx context.Context) (ret []byte, err error)
- func (mr *MessageReader) Next(ctx context.Context) ([]byte, error)
- func (r *MessageReader) PeekByte(ctx context.Context) (out byte, err error)
- type MsgCancel
- type MsgColumn
- type MsgDone
- type MsgEnvChange
- type MsgEom
- type MsgFinalDone
- type MsgOrder
- type MsgOther
- type MsgParamValue
- type MsgRow
- type MsgRowCount
- type MsgRpcResult
- type MsgStatus
- type PacketReader
- type PacketType
- type PacketWriter
- func (tds *PacketWriter) BeginMessage(ctx context.Context, PacketType PacketType, reset bool) error
- func (tds *PacketWriter) EndMessage(ctx context.Context) error
- func (tds *PacketWriter) Login(ctx context.Context, config *rdb.Config) error
- func (tds *PacketWriter) PreLogin(ctx context.Context, instance string, encrypt EncryptAvailable) error
- func (tds *PacketWriter) Write(ctx context.Context, bb []byte) (n int, err error)
- func (tds *PacketWriter) WriteBuffer(v []byte) (n int)
- func (tds *PacketWriter) WriteByte(v byte) (n int)
- func (tds *PacketWriter) WriteUint16(v uint16) (n int)
- func (tds *PacketWriter) WriteUint32(v uint32) (n int)
- func (tds *PacketWriter) WriteUint64(v uint64) (n int)
- type SQLColumn
- type ServerConnection
- type ServerInfo
- type UnexpectedMessage
Constants ¶
View Source
const ( TypeOldBool rdb.Type = rdb.TypeDriverThresh + iota TypeOldByte TypeOldInt16 TypeOldInt32 TypeOldInt64 TypeOldFloat32 TypeOldFloat64 TypeOldTD // DateTime TypeNumeric )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bulk ¶ added in v1.2.0
type Connection ¶
type Connection struct {
ProductVersion *semver.Version
ProtocolVersion *semver.Version
Encrypted bool
// contains filtered or unexported fields
}
func NewConnection ¶
func NewConnection(c net.Conn, defaultResetTimeout, RollbackTimeout time.Duration) *Connection
func (*Connection) Available ¶
func (tds *Connection) Available() bool
func (*Connection) Begin ¶
func (tds *Connection) Begin(ctx context.Context, iso rdb.IsolationLevel) error
func (*Connection) Close ¶
func (tds *Connection) Close()
func (*Connection) ConnectionInfo ¶
func (tds *Connection) ConnectionInfo() *rdb.ConnectionInfo
func (*Connection) NextResult ¶
func (tds *Connection) NextResult(ctx context.Context) (more bool, err error)
func (*Connection) Open ¶
func (tds *Connection) Open(ctx context.Context, config *rdb.Config) (*ServerInfo, error)
func (*Connection) Opened ¶ added in v1.0.4
func (tds *Connection) Opened() time.Time
func (*Connection) Prepare ¶
func (tds *Connection) Prepare(*rdb.Command) (preparedStatementToken interface{}, err error)
func (*Connection) Query ¶
func (tds *Connection) Query(ctx context.Context, cmd *rdb.Command, params []rdb.Param, preparedToken interface{}, valuer rdb.DriverValuer) error
func (*Connection) Rollback ¶
func (tds *Connection) Rollback(savepoint string) error
func (*Connection) SavePoint ¶
func (tds *Connection) SavePoint(ctx context.Context, name string) error
func (*Connection) SetAvailable ¶
func (tds *Connection) SetAvailable(available bool)
func (*Connection) Status ¶
func (tds *Connection) Status() rdb.DriverConnStatus
func (*Connection) Unprepare ¶
func (tds *Connection) Unprepare(preparedStatementToken interface{}) (err error)
type Driver ¶
type Driver struct{}
func (*Driver) DriverInfo ¶
func (dr *Driver) DriverInfo() *rdb.DriverInfo
func (*Driver) PingCommand ¶
type EncryptAvailable ¶
type EncryptAvailable byte
type InputToolong ¶
type InputToolong struct {
DataLen, TypeLen uint32
}
func (InputToolong) Error ¶
func (err InputToolong) Error() string
type MessageReader ¶
type MessageReader struct {
// contains filtered or unexported fields
}
func (*MessageReader) Close ¶
func (mr *MessageReader) Close() error
func (*MessageReader) FetchAll ¶
func (r *MessageReader) FetchAll(ctx context.Context) (ret []byte, err error)
type MsgEnvChange ¶
type MsgEnvChange struct{}
type MsgFinalDone ¶
type MsgFinalDone struct{}
type MsgParamValue ¶
type MsgParamValue struct{}
type MsgRowCount ¶
type MsgRowCount struct {
Count uint64
}
type MsgRpcResult ¶
type MsgRpcResult int32
type PacketReader ¶
type PacketReader struct {
// contains filtered or unexported fields
}
func NewPacketReader ¶
func NewPacketReader(r sbuffer.ConnReadDeadline) *PacketReader
func (*PacketReader) BeginMessage ¶
func (tds *PacketReader) BeginMessage(_ context.Context, expectType PacketType) *MessageReader
func (*PacketReader) LoginAck ¶
func (tds *PacketReader) LoginAck(ctx context.Context) (*ServerInfo, error)
func (*PacketReader) Prelogin ¶
func (tds *PacketReader) Prelogin(ctx context.Context) (*ServerConnection, error)
type PacketType ¶
type PacketType byte
type PacketWriter ¶
type PacketWriter struct {
PacketType PacketType
// contains filtered or unexported fields
}
func NewPacketWriter ¶
func NewPacketWriter(w connWriteDeadline) *PacketWriter
func (*PacketWriter) BeginMessage ¶
func (tds *PacketWriter) BeginMessage(ctx context.Context, PacketType PacketType, reset bool) error
func (*PacketWriter) EndMessage ¶
func (tds *PacketWriter) EndMessage(ctx context.Context) error
func (*PacketWriter) PreLogin ¶
func (tds *PacketWriter) PreLogin(ctx context.Context, instance string, encrypt EncryptAvailable) error
Pre-Login
func (*PacketWriter) WriteBuffer ¶
func (tds *PacketWriter) WriteBuffer(v []byte) (n int)
func (*PacketWriter) WriteByte ¶
func (tds *PacketWriter) WriteByte(v byte) (n int)
func (*PacketWriter) WriteUint16 ¶
func (tds *PacketWriter) WriteUint16(v uint16) (n int)
func (*PacketWriter) WriteUint32 ¶
func (tds *PacketWriter) WriteUint32(v uint32) (n int)
func (*PacketWriter) WriteUint64 ¶
func (tds *PacketWriter) WriteUint64(v uint64) (n int)
type ServerConnection ¶
type ServerConnection struct {
Version [6]byte
Encryption EncryptAvailable
Instance string
MARS bool
}
Rturned from Pre-Login.
type ServerInfo ¶
type ServerInfo struct {
AcceptTSql bool
TdsVersion [4]byte
ProgramName string
MajorVersion byte
MinorVersion byte
BuildNumber uint16
}
Returned from Login.
func (*ServerInfo) String ¶
func (si *ServerInfo) String() string
type UnexpectedMessage ¶
type UnexpectedMessage struct {
Expected PacketType
Received PacketType
}
func (UnexpectedMessage) Error ¶
func (msg UnexpectedMessage) Error() string
Source Files
¶
Click to show internal directories.
Click to hide internal directories.