monet

package module
v0.0.0-...-00670ff Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2018 License: BSD-3-Clause Imports: 21 Imported by: 0

README

implementing monetdb compliant to database/sql/driver
monet.LogWriter will log Server activity.
TODO:
a.) extend live test suite
b.) clear type compatibility
c.) check if there are encoding issues, if driver used on mac os

Documentation

Overview

The monetdb mapi server handshake needs the crypt algorithm.

Package monet implements the database/sql/driver interfaces for the monetdb database (http://monetdb.org).

example:

import (
	"database/sql"
	"monet"
	"time"
)

db, err := sql.Open(monet.DRV_NAME, monet.ConnectionString("localhost", "50000", "monetdb", "monetdb", "voc", time.Second*10))
...

Currently only default driver.Value data types are supported. Server implements the mapi protocol as defined for the monetdb. You usually don't need it. Placeholders currently only work for driver.Value. The Server has a global logger for all connections. By default nothing is logged. You can switch globally to another logger:

monet.MapiLogger = syslog.New(...)

or

monet.MapiLogger = monet.DebugToStderr

or

monet.MapiLogger = monet.New(writer, prefix, logFlags, logLevel)

Index

Constants

View Source
const (
	SQLPlaceholder = "%s"
	RowsSize       = 100
)
View Source
const (
	CHAR     = "char"    // (L) character string with length L
	VARCHAR  = "varchar" // (L) string with atmost length L
	CLOB     = "clob"
	BLOB     = "blob"
	DECIMAL  = "decimal"  // (P,S)
	SMALLINT = "smallint" // 16 bit integer
	INT      = "int"      // 32 bit integer
	BIGINT   = "bigint"   // 64 bit integer
	SERIAL   = "serial"   // special 64 bit integer (sequence generator)
	REAL     = "real"     // 32 bit floating point
	DOUBLE   = "double"   // 64 bit floating point
	BOOLEAN  = "boolean"
	//DATE      = "date"
	//TIME      = "time"      // (T) time of day
	TIMESTAMP = "timestamp" // (T) date concatenated with unique time

	//MONTH_INTERVAL = "month_interval"
	//SEC_INTERVAL   = "sec_interval"
	WRD = "wrd"

	TINYINT   = "tinyint"
	SHORTINT  = "shortint"
	MEDIUMINT = "mediumint"
	LONGINT   = "longint"
	FLOAT     = "float"
)

type codes in comments currently not supported by go driver

View Source
const (
	DRV_NAME = "monet"
)
View Source
const (
	MAX_PACKAGE_LENGTH = (1024 * 8) - 2
)
View Source
const TimeLayout = "2006-01-02 15:04:05.000000"

Variables

This section is empty.

Functions

func ConnectionString

func ConnectionString(hostname, port, username, password, database string, timeout time.Duration) string

Returns the dataSourceName for

db, err := sql.Open(monet.DRV_NAME, dataSourceName)

func Crypt

func Crypt(key, slash string) (digest string, err error)

Types

type LogWriter

type LogWriter interface {
	Err(m string) (err error)
	Warning(m string) (err error)
	Info(m string) (err error)
	Debug(m string) (err error)
}

The logger for the monetdb driver Server instance. *syslog.Writer is compliant to this interface.

var DebugToStderr LogWriter = New(os.Stderr, "go/monet ", log.LstdFlags, syslog.LOG_DEBUG)

Logs everything to stderr and can be plugged in via

monet.MapiLogger = DebugToStderr
var MapiLogger LogWriter = new(nolog)

func New

func New(writer io.Writer, prefix string, flag int, logLevel syslog.Priority) LogWriter

type Server

type Server interface {
	Cmd(operation string) (string, error)
	Connect(hostname, port, username, password, database, language string, timeout time.Duration) error
	Disconnect() error
}

A low level connection to the monetdb mapi server.

func CreateServer

func CreateServer(logger LogWriter) Server

func NewServer

func NewServer() Server

Jump to

Keyboard shortcuts

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