mapi

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2024 License: MPL-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MDB_CHAR      = "char"    // (L) character string with length L
	MDB_VARCHAR   = "varchar" // (L) string with atmost length L
	MDB_CLOB      = "clob"
	MDB_BLOB      = "blob"
	MDB_DECIMAL   = "decimal"  // (P,S)
	MDB_SMALLINT  = "smallint" // 16 bit integer
	MDB_INT       = "int"      // 32 bit integer
	MDB_BIGINT    = "bigint"   // 64 bit integer
	MDB_HUGEINT   = "hugeint"  // 64 bit integer
	MDB_SERIAL    = "serial"   // special 64 bit integer sequence generator
	MDB_REAL      = "real"     // 32 bit floating point
	MDB_DOUBLE    = "double"   // 64 bit floating point
	MDB_BOOLEAN   = "boolean"
	MDB_DATE      = "date"
	MDB_NULL      = "NULL"
	MDB_TIME      = "time"      // (T) time of day
	MDB_TIMESTAMP = "timestamp" // (T) date concatenated with unique time
	MDB_INTERVAL  = "interval"  // (Q) a temporal interval

	MDB_MONTH_INTERVAL = "month_interval"
	MDB_SEC_INTERVAL   = "sec_interval"
	MDB_WRD            = "wrd"
	MDB_TINYINT        = "tinyint"

	// Not on the website:
	MDB_SHORTINT    = "shortint"
	MDB_MEDIUMINT   = "mediumint"
	MDB_LONGINT     = "longint"
	MDB_FLOAT       = "float"
	MDB_TIMESTAMPTZ = "timestamptz"
)
View Source
const (
	MAPI_ARRAY_SIZE = 100
)

Variables

This section is empty.

Functions

func ConvertToMonet

func ConvertToMonet(value Value) (string, error)

func Cut

func Cut(s, sep string) (before, after string, found bool)

Types

type Date

type Date struct {
	Year  int
	Month time.Month
	Day   int
}

Time represents MonetDB's Date datatype.

func GetDate

func GetDate(t time.Time) Date

GetDate takes the date part of a time.Time and put it in a Date

func (Date) String

func (d Date) String() string

String returns a string representation of a Date in the form "YYYY-MM-DD"

func (Date) Time

func (d Date) Time() time.Time

Time converts to time.Time. The time is set to 00:00:00.

type MapiConn

type MapiConn struct {
	Hostname string
	Port     int
	Username string
	Password string
	Database string
	Language string

	State int
	// contains filtered or unexported fields
}

MapiConn is a MonetDB's MAPI connection handle.

The values in the handle are initially set according to the values that are provided when calling NewMapi. However, they may change depending on how the MonetDB server redirects the connection. The final values are available after the connection is made by calling the Connect() function.

The State value can be either MAPI_STATE_INIT or MAPI_STATE_READY.

func NewMapi

func NewMapi(name string) (*MapiConn, error)

NewMapi returns a MonetDB's MAPI connection handle.

To establish the connection, call the Connect() function.

func (*MapiConn) Connect

func (c *MapiConn) Connect() error

Connect starts a MAPI connection to MonetDB server.

func (*MapiConn) Disconnect

func (c *MapiConn) Disconnect()

Disconnect closes the connection.

func (*MapiConn) Execute

func (c *MapiConn) Execute(query string) (string, error)

func (*MapiConn) FetchNext

func (c *MapiConn) FetchNext(queryId int, offset int, amount int) (string, error)

func (*MapiConn) SetAutoCommit

func (c *MapiConn) SetAutoCommit(enable bool) (string, error)

func (*MapiConn) SetReplySize

func (c *MapiConn) SetReplySize(size int) (string, error)

func (*MapiConn) SetSizeHeader

func (c *MapiConn) SetSizeHeader(enable bool) (string, error)

type Metadata

type Metadata struct {
	ExecId      int
	LastRowId   int
	RowCount    int
	QueryId     int
	Offset      int
	ColumnCount int
}

type Query

type Query struct {
	Mapi     *MapiConn
	SqlQuery string
}

func (*Query) ExecuteNamedQuery

func (q *Query) ExecuteNamedQuery(r *ResultSet, names []string, args []Value) (string, error)

func (*Query) ExecutePreparedQuery

func (q *Query) ExecutePreparedQuery(r *ResultSet, args []Value) (string, error)

func (*Query) ExecuteQuery

func (q *Query) ExecuteQuery(r *ResultSet) (string, error)

func (*Query) PrepareQuery

func (q *Query) PrepareQuery(r *ResultSet) error

type ResultSet

type ResultSet struct {
	Metadata Metadata
	Schema   []TableElement
	Rows     [][]Value
}

func (*ResultSet) CreateExecString

func (s *ResultSet) CreateExecString(args []Value) (string, error)

func (*ResultSet) CreateNamedString

func (s *ResultSet) CreateNamedString(query string, names []string, args []Value) (string, error)

func (*ResultSet) StoreResult

func (s *ResultSet) StoreResult(r string) error

type TableElement

type TableElement struct {
	ColumnName   string
	ColumnType   string
	DisplaySize  int
	InternalSize int
	Precision    int
	Scale        int
	NullOk       int
}

type Time

type Time struct {
	Hour, Min, Sec int
}

Time represents MonetDB's Time datatype.

func GetTime

func GetTime(t time.Time) Time

GetTime takes the clock part of a time.Time and put it in a Time

func (Time) String

func (t Time) String() string

String returns a string representation of a Time in the form "HH:YY:MM".

func (Time) Time

func (t Time) Time() time.Time

Time converts to time.Time. The date is set to January 1, 1970.

type Value

type Value interface{}

Jump to

Keyboard shortcuts

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