sqlitecloud

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

README

SQLite Cloud Client SDK for Go

The SQLite Cloud Client SDK for Go (sqlitecloud/go-sdk) is the Go Programming Language application programmer's interface to SQLite Cloud. It is a set of library functions that allow client programs to pass queries and SQL commands to the SQLite Cloud backend server and to receive the results of these queries. In addition to the standard SQLite statements, several other commands are supported.

Getting Started

Use the SQLite Cloud Client SDK in your Go code
  1. Import the package in your Go source code:

    import sqlitecloud "github.com/sqlitecloud/go-sdk"
    
  2. Download the package, and run the go mod tidy command to synchronize your module's dependencies:

    $ go mod tidy 
    go: downloading github.com/sqlitecloud/go-sdk v1.0.0
    
  3. Connect to a SQLite Cloud database with a valid connection string:

    db, err := sqlitecloud.Connect("sqlitecloud://user:pass@host.sqlite.cloud:port/dbname")
    
  4. Execute queries using a method defined on the SQCloud struct, for example Select:

    result, _ := db.Select("SELECT * FROM table1;")
    

The following example shows how to print the content of the table table1:

package main

import (
    "fmt"
    "strings"

    sqlitecloud "github.com/sqlitecloud/go-sdk"
)

const connectionString = "sqlitecloud://admin:password@host.sqlite.cloud:8860/dbname.sqlite"

func main() {
    db, err := sqlitecloud.Connect(connectionString)
    if err != nil {
        fmt.Println("Connect error: ", err)
    }

    tables, _ := db.ListTables()
    fmt.Printf("Tables:\n\t%s\n", strings.Join(tables, "\n\t"))

    fmt.Printf("Table1:\n")
    result, _ := db.Select("SELECT * FROM t1;")
    for r := uint64(0); r < result.GetNumberOfRows(); r++ {
        id, _ := result.GetInt64Value(r, 0)
        value, _ := result.GetStringValue(r, 1)
        fmt.Printf("\t%d: %s\n", id, value)
    }
}

Get a connection string

You can connect to any cloud database using a special connection string in the form:

sqlitecloud://user:pass@host.com:port/dbname?timeout=10&key2=value2&key3=value3

To get a valid connection string, follow these instructions:

API Documentation

The complete documentation of the sqlitecloud/go-sdk library is available at: https://pkg.go.dev/github.com/sqlitecloud/go-sdk

Documentation

Index

Constants

View Source
const (
	CMD_STRING       = '+'
	CMD_ZEROSTRING   = '!'
	CMD_ERROR        = '-'
	CMD_INT          = ':'
	CMD_FLOAT        = ','
	CMD_ROWSET       = '*'
	CMD_ROWSET_CHUNK = '/'
	CMD_JSON         = '#'
	CMD_RAWJSON      = '{'
	CMD_NULL         = '_'
	CMD_BLOB         = '$'
	CMD_COMPRESSED   = '%'
	CMD_PUBSUB       = '|'
	CMD_COMMAND      = '^'
	CMD_RECONNECT    = '@'
	CMD_ARRAY        = '='
)
View Source
const (
	NO_EXTCODE = 0
	NO_OFFCODE = -1
)
View Source
const OUTFORMAT_BOX = 9
View Source
const OUTFORMAT_CSV = 1
View Source
const OUTFORMAT_HTML = 6
View Source
const OUTFORMAT_JSON = 5
View Source
const OUTFORMAT_LINE = 4
View Source
const OUTFORMAT_LIST = 0
View Source
const OUTFORMAT_MARKDOWN = 7
View Source
const OUTFORMAT_QUOTE = 2
View Source
const OUTFORMAT_TABLE = 8
View Source
const OUTFORMAT_TABS = 3
View Source
const OUTFORMAT_XML = 10
View Source
const ROWSET_TYPE_BASIC = 1
View Source
const ROWSET_TYPE_DATA_ONLY = 4
View Source
const ROWSET_TYPE_HEADER_ONLY = 3
View Source
const ROWSET_TYPE_METADATA_v1 = 2
View Source
const SQLiteCloudCA = "SQLiteCloudCA"

Variables

View Source
var OKResult = Result{

	MaxHeaderWidth: 0,
	// contains filtered or unexported fields
}

Functions

func GetDefaultSeparatorForOutputFormat

func GetDefaultSeparatorForOutputFormat(Format int) (string, error)

func GetOutputFormatFromString

func GetOutputFormatFromString(Format string) (int, error)

func ParseTlsString

func ParseTlsString(tlsconf string) (secure bool, tlsInsecureSkipVerify bool, pem string)

func SQCloudEnquoteString

func SQCloudEnquoteString(s string) string

SQCloudEnquoteString enquotes the given string if necessary and returns the result as a news created string. If the given string contains a '"', the '"' is properly escaped. If the given string contains one or more spaces, the whole string is enquoted with '"'

Types

type Chunk

type Chunk struct {
	DataBufferOffset uint64
	LEN              uint64
	RAW              []byte
}

func (*Chunk) GetChunkSize

func (this *Chunk) GetChunkSize() uint64

func (*Chunk) GetData

func (this *Chunk) GetData() []byte

func (*Chunk) GetType

func (this *Chunk) GetType() byte

func (*Chunk) IsCompressed

func (this *Chunk) IsCompressed() bool

func (*Chunk) Uncompress

func (this *Chunk) Uncompress() error

type Result

type Result struct {

	// columns metadata
	Name     []string
	Width    []uint64
	DeclType []string
	DbName   []string
	TblName  []string
	OrigName []string
	Notnull  []int32
	PriKey   []int32
	Autoinc  []int32

	MaxHeaderWidth uint64
	// contains filtered or unexported fields
}

The Result is either a Literal or a RowSet

func (*Result) Dump

func (this *Result) Dump()

Dump outputs this query result to the screen. Warning: No line truncation is used. If you want to truncation the output to a certain width, use: Result.DumpToScreen( width )

func (*Result) DumpToScreen

func (this *Result) DumpToScreen(MaxLineLength uint)

DumpToScreen outputs this query result to the screen. The output is truncated at a maximum line width of MaxLineLength runes (compare: Result.Dump())

func (*Result) DumpToWriter

func (this *Result) DumpToWriter(Out *bufio.Writer, Format int, NoHeader bool, Separator string, NullValue string, NewLine string, MaxLineLength uint, SuppressOK bool) (int, error)

DumpToWriter renders this query result into the buffer of an io.Writer. The output Format can be specified and must be one of the following values: OUTFORMAT_LIST, OUTFORMAT_CSV, OUTFORMAT_QUOTE, OUTFORMAT_TABS, OUTFORMAT_LINE, OUTFORMAT_JSON, OUTFORMAT_HTML, OUTFORMAT_MARKDOWN, OUTFORMAT_TABLE, OUTFORMAT_BOX The Separator argument specifies the column separating string (default: '|'). All lines are truncated at MaxLineLeength. A MaxLineLangth of '0' means no truncation. If this query result is of type RESULT_OK and SuppressOK is set to false, an "OK" string is written to the buffer, otherwise nothing is written to the buffer.

func (*Result) Free

func (this *Result) Free()

Free frees all memory allocated by this query result.

func (*Result) GetBuffer

func (this *Result) GetBuffer() []byte

GetBuffer returns the buffer of this query result as string.

func (*Result) GetBufferLength

func (this *Result) GetBufferLength() (uint64, error)

GetBufferLength returns the length of the buffer of this query result.

func (*Result) GetError

func (this *Result) GetError() (int, int, int, string, error)

GetError returns the ErrorCode, ExtErrorCode, ErrorOffset, ErrorMessage and the error object of the receiver

func (*Result) GetErrorAsString

func (this *Result) GetErrorAsString() string

func (*Result) GetError_

func (this *Result) GetError_() (int, string)

func (*Result) GetFirstRow

func (this *Result) GetFirstRow() (*ResultRow, error)

GetFirstRow returns the first row of this query result. If this query result has no row's, nil is returned instead.

func (*Result) GetFloat32

func (this *Result) GetFloat32() (float32, error)

func (*Result) GetFloat32Value

func (this *Result) GetFloat32Value(Row uint64, Column uint64) (float32, error)

GetFloat32Value returns the contents in row Row and column Column of this query result as float32. The Row index is an unsigned int in the range of 0...GetNumberOfRows() - 1. The Column index is an unsigned int in the range of 0...GetNumberOfColumns() - 1.

func (*Result) GetFloat32Value_

func (this *Result) GetFloat32Value_(Row uint64, Column uint64) float32

func (*Result) GetFloat32_

func (this *Result) GetFloat32_() float32

func (*Result) GetFloat64

func (this *Result) GetFloat64() (float64, error)

func (*Result) GetFloat64Value

func (this *Result) GetFloat64Value(Row uint64, Column uint64) (float64, error)

GetFloat64Value returns the contents in row Row and column Column of this query result as float64. The Row index is an unsigned int in the range of 0...GetNumberOfRows() - 1. The Column index is an unsigned int in the range of 0...GetNumberOfColumns() - 1.

func (*Result) GetFloat64Value_

func (this *Result) GetFloat64Value_(Row uint64, Column uint64) float64

func (*Result) GetFloat64_

func (this *Result) GetFloat64_() float64

func (*Result) GetInt32

func (this *Result) GetInt32() (int32, error)

func (*Result) GetInt32Value

func (this *Result) GetInt32Value(Row uint64, Column uint64) (int32, error)

GetInt32Value returns the contents in row Row and column Column of this query result as int32. The Row index is an unsigned int in the range of 0...GetNumberOfRows() - 1. The Column index is an unsigned int in the range of 0...GetNumberOfColumns() - 1.

func (*Result) GetInt32Value_

func (this *Result) GetInt32Value_(Row uint64, Column uint64) int32

func (*Result) GetInt32_

func (this *Result) GetInt32_() int32

func (*Result) GetInt64

func (this *Result) GetInt64() (int64, error)

func (*Result) GetInt64Value

func (this *Result) GetInt64Value(Row uint64, Column uint64) (int64, error)

GetInt64Value returns the contents in row Row and column Column of this query result as int64. The Row index is an unsigned int in the range of 0...GetNumberOfRows() - 1. The Column index is an unsigned int in the range of 0...GetNumberOfColumns() - 1.

func (*Result) GetInt64Value_

func (this *Result) GetInt64Value_(Row uint64, Column uint64) int64

func (*Result) GetInt64_

func (this *Result) GetInt64_() int64

func (*Result) GetJSON

func (this *Result) GetJSON() (object interface{}, err error)

func (*Result) GetJSON_

func (this *Result) GetJSON_() (object interface{})

func (*Result) GetLastRow

func (this *Result) GetLastRow() (*ResultRow, error)

GetLastRow returns the first row of this query result. If this query result has no row's, nil is returned instead.

func (*Result) GetMaxColumnWidth

func (this *Result) GetMaxColumnWidth(Column uint64) (uint64, error)

GetMaxColumnLength returns the number of runes of the value in the specified column with the maximum length in this query result. The Column index is an unsigned int in the range of 0...GetNumberOfColumns() - 1.

func (*Result) GetMaxNameWidth

func (this *Result) GetMaxNameWidth() uint64

GetMaxNameWidth returns the number of runes of the longest column name.

func (*Result) GetName

func (this *Result) GetName(Column uint64) (string, error)

GetName returns the column name in column Column of this query result. The Column index is an unsigned int in the range of 0...GetNumberOfColumns() - 1.

func (*Result) GetNameLength

func (this *Result) GetNameLength(Column uint64) (uint64, error)

GetNameWidth returns the number of runes of the column name in the specified column. The Column index is an unsigned int in the range of 0...GetNumberOfColumns() - 1.

func (*Result) GetName_

func (this *Result) GetName_(Column uint64) string

func (*Result) GetNumberOfColumns

func (this *Result) GetNumberOfColumns() uint64

GetNumberOfColumns returns the number of columns in this query result

func (*Result) GetNumberOfRows

func (this *Result) GetNumberOfRows() uint64

GetNumberOfRows returns the number of rows in this query result

func (*Result) GetRow

func (this *Result) GetRow(Row uint64) (*ResultRow, error)

GetRow returns a pointer to the row Row of this query result. The Row index is an unsigned int in the range of 0...GetNumberOfRows() - 1. If the index row can not be found, nil is returned instead.

func (*Result) GetSQLDateTime

func (this *Result) GetSQLDateTime(Row uint64, Column uint64) (time.Time, error)

GetSQLDateTime parses this query result value in Row and Column as an SQL-DateTime and returns its value. The Row index is an unsigned int in the range of 0...GetNumberOfRows() - 1. The Column index is an unsigned int in the range of 0...GetNumberOfColumns() - 1.

func (*Result) GetSQLDateTime_

func (this *Result) GetSQLDateTime_(Row uint64, Column uint64) time.Time

func (*Result) GetString

func (this *Result) GetString() (string, error)

func (*Result) GetStringValue

func (this *Result) GetStringValue(Row uint64, Column uint64) (string, error)

GetStringValue returns the contents in row Row and column Column of this query result as string. The Row index is an unsigned int in the range of 0...GetNumberOfRows() - 1. The Column index is an unsigned int in the range of 0...GetNumberOfColumns() - 1.

func (*Result) GetStringValue_

func (this *Result) GetStringValue_(Row uint64, Column uint64) string

func (*Result) GetString_

func (this *Result) GetString_() string

func (*Result) GetType

func (this *Result) GetType() byte

GetType returns the type of this query result as an integer (see: RESULT_ constants).

func (*Result) GetUncompressedChuckSizeSum

func (this *Result) GetUncompressedChuckSizeSum() uint64

GetUncompressedChuckSizeSum returns the

func (*Result) GetValue

func (this *Result) GetValue(Row uint64, Column uint64) (*Value, error)

func (*Result) GetValueType

func (this *Result) GetValueType(Row uint64, Column uint64) (byte, error)

GetValueType returns the type of the value in row Row and column Column of this query result. The Row index is an unsigned int in the range of 0...GetNumberOfRows() - 1. The Column index is an unsigned int in the range of 0...GetNumberOfColumns() - 1. Possible return types are: VALUE_INTEGER, VALUE_FLOAT, VALUE_TEXT, VALUE_BLOB, VALUE_NULL

func (*Result) GetValueType_

func (this *Result) GetValueType_(Row uint64, Column uint64) byte

func (*Result) IsArray

func (this *Result) IsArray() bool

func (*Result) IsBLOB

func (this *Result) IsBLOB() bool

func (*Result) IsCommand

func (this *Result) IsCommand() bool

IsCommand returns true if this query result is of type "RESULT_XXXXXXX", false otherwise.

func (*Result) IsError

func (this *Result) IsError() bool

IsError returns true if this query result is of type "RESULT_ERROR", false otherwise.

func (*Result) IsFloat

func (this *Result) IsFloat() bool

IsFloat returns true if this query result is of type "RESULT_FLOAT", false otherwise.

func (*Result) IsInteger

func (this *Result) IsInteger() bool

IsInteger returns true if this query result is of type "RESULT_INTEGER", false otherwise.

func (*Result) IsJSON

func (this *Result) IsJSON() bool

IsJson returns true if this query result is of type "RESULT_JSON", false otherwise.

func (*Result) IsLiteral

func (this *Result) IsLiteral() bool

func (*Result) IsNULL

func (this *Result) IsNULL() bool

IsNull returns true if this query result is of type "RESULT_NULL", false otherwise.

func (*Result) IsOK

func (this *Result) IsOK() bool

IsOK returns true if this query result if of type "RESULT_OK", false otherwise.

func (*Result) IsPSUB

func (this *Result) IsPSUB() bool

IsPSUB returns true if this query result is of type "RESULT_XXXXXXX", false otherwise.

func (*Result) IsReconnect

func (this *Result) IsReconnect() bool

IsReconnect returns true if this query result is of type "RESULT_XXXXXXX", false otherwise.

func (*Result) IsRowSet

func (this *Result) IsRowSet() bool

IsRowSet returns true if this query result is of type "RESULT_ROWSET", false otherwise.

func (*Result) IsString

func (this *Result) IsString() bool

IsString returns true if this query result is of type "RESULT_STRING", false otherwise.

func (*Result) IsText

func (this *Result) IsText() bool

IsText returns true if this query result is of type "RESULT_JSON", "RESULT_STRING", "RESULT_INTEGER" or "RESULT_FLOAT", false otherwise.

func (*Result) Rows

func (this *Result) Rows() []ResultRow

func (*Result) ToJSON

func (this *Result) ToJSON() string

ToJSON returns a JSON representation of this query result.

type ResultRow

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

func (*ResultRow) DumpToWriter

func (this *ResultRow) DumpToWriter(Out io.Writer, Format int, Separator string, NullValue string, NewLine string, MaxLineLength uint) (int, error)

DumpToWriter renders this query result row into the buffer of an io.Writer. The output Format can be specified and must be one of the following values: OUTFORMAT_LIST, OUTFORMAT_CSV, OUTFORMAT_QUOTE, OUTFORMAT_TABS, OUTFORMAT_LINE, OUTFORMAT_JSON, OUTFORMAT_HTML, OUTFORMAT_MARKDOWN, OUTFORMAT_TABLE, OUTFORMAT_BOX The Separator argument specifies the column separating string (default: '|'). All lines are truncated at MaxLineLeength. A MaxLineLangth of '0' means no truncation.

func (*ResultRow) GetFloat32

func (this *ResultRow) GetFloat32(Column uint64) (float32, error)

GetFloat32Value returns the contents in column Column of this query result row as float32. The Column index is an unsigned int in the range of 0...GetNumberOfColumns() - 1.

func (*ResultRow) GetFloat64

func (this *ResultRow) GetFloat64(Column uint64) (float64, error)

GetFloat64Value returns the contents in column Column of this query result row as float64. The Column index is an unsigned int in the range of 0...GetNumberOfColumns() - 1.

func (*ResultRow) GetInt32

func (this *ResultRow) GetInt32(Column uint64) (int32, error)

GetInt32Value returns the contents in column Column of this query result row as int32. The Column index is an unsigned int in the range of 0...GetNumberOfColumns() - 1.

func (*ResultRow) GetInt64

func (this *ResultRow) GetInt64(Column uint64) (int64, error)

GetInt64Value returns the contents in column Column of this query result row as int64. The Column index is an unsigned int in the range of 0...GetNumberOfColumns() - 1.

func (*ResultRow) GetMaxNameLength

func (this *ResultRow) GetMaxNameLength() uint64

GetMaxNameLength returns the number of runes of the longest column name.

func (*ResultRow) GetMaxWidth

func (this *ResultRow) GetMaxWidth(Column uint64) (uint64, error)

GetMaxWidth returns the number of runes of the value in the specified column with the maximum length in this query result. The Column index is an unsigned int in the range of 0...GetNumberOfColumns() - 1.

func (*ResultRow) GetName

func (this *ResultRow) GetName(Column uint64) (string, error)

GetName returns the column name in column Column of this query result. The Column index is an unsigned int in the range of 0...GetNumberOfColumns() - 1.

func (*ResultRow) GetNameLength

func (this *ResultRow) GetNameLength(Column uint64) (uint64, error)

GetNameLength returns the number of runes of the column name in the specified column. The Column index is an unsigned int in the range of 0...GetNumberOfColumns() - 1.

func (*ResultRow) GetNumberOfColumns

func (this *ResultRow) GetNumberOfColumns() uint64

func (*ResultRow) GetSQLDateTime

func (this *ResultRow) GetSQLDateTime(Column uint64) (time.Time, error)

GetSQLDateTime parses this query result value in column Column as an SQL-DateTime and returns its value. The Column index is an unsigned int in the range of 0...GetNumberOfColumns() - 1.

func (*ResultRow) GetString

func (this *ResultRow) GetString(Column uint64) (string, error)

GetStringValue returns the contents in column Column of this query result row as string. The Column index is an unsigned int in the range of 0...GetNumberOfColumns() - 1.

func (*ResultRow) GetType

func (this *ResultRow) GetType(Column uint64) (byte, error)

GetType returns the type of the value in column Column of this query result row. The Column index is an unsigned int in the range of 0...GetNumberOfColumns() - 1. Possible return types are: VALUE_INTEGER, VALUE_FLOAT, VALUE_TEXT, VALUE_BLOB, VALUE_NULL

func (*ResultRow) GetValue

func (this *ResultRow) GetValue(Column uint64) (*Value, error)

func (*ResultRow) IsBLOB

func (this *ResultRow) IsBLOB(Column uint64) bool

IsBLOB returns true if this query result row column Column is of type "VALUE_BLOB", false otherwise. The Column index is an unsigned int in the range of 0...GetNumberOfColumns() - 1.

func (*ResultRow) IsEOF

func (this *ResultRow) IsEOF() bool

IsEOF returns false if this query result row is in the result set, true otherwise.

func (*ResultRow) IsFirst

func (this *ResultRow) IsFirst() bool

IsFirst returns true if this query result row is the first in the result set, false otherwise.

func (*ResultRow) IsFloat

func (this *ResultRow) IsFloat(Column uint64) bool

IsFloat returns true if this query result row column Column is of type "VALUE_FLOAT", false otherwise. The Column index is an unsigned int in the range of 0...GetNumberOfColumns() - 1.

func (*ResultRow) IsInteger

func (this *ResultRow) IsInteger(Column uint64) bool

IsInteger returns true if this query result row column Column is of type "VALUE_INTEGER", false otherwise. The Column index is an unsigned int in the range of 0...GetNumberOfColumns() - 1.

func (*ResultRow) IsLast

func (this *ResultRow) IsLast() bool

IsLast returns true if this query result row is the last in the result set, false otherwise.

func (*ResultRow) IsNULL

func (this *ResultRow) IsNULL(Column uint64) bool

IsNULL returns true if this query result row column Column is of type "VALUE_NULL", false otherwise. The Column index is an unsigned int in the range of 0...GetNumberOfColumns() - 1.

func (*ResultRow) IsString

func (this *ResultRow) IsString(Column uint64) bool

IsString returns true if this query result row column Column is of type "VALUE_TEXT", false otherwise. The Column index is an unsigned int in the range of 0...GetNumberOfColumns() - 1.

func (*ResultRow) IsText

func (this *ResultRow) IsText(Column uint64) bool

IsText returns true if this query result row column Column is of type "VALUE_TEXT" or "VALUE_BLOB", false otherwise. The Column index is an unsigned int in the range of 0...GetNumberOfColumns() - 1.

func (*ResultRow) Next

func (this *ResultRow) Next() *ResultRow

Next fetches the next row in this query result and returns it, otherwise if there is no next row, nil is returned.

func (*ResultRow) Rewind

func (this *ResultRow) Rewind() *ResultRow

Rewind resets the iterator and returns the first row in this query result.

func (*ResultRow) ToJSON

func (this *ResultRow) ToJSON() ([]byte, error)

ToJSON returns a JSON representation of this query result row.

type SQCloud

type SQCloud struct {
	SQCloudConfig

	// psubc    chan string
	Callback func(*SQCloud, string)

	ErrorCode    int
	ExtErrorCode int
	ErrorOffset  int
	ErrorMessage string
	// contains filtered or unexported fields
}

func Connect

func Connect(ConnectionString string) (*SQCloud, error)

Connect creates a new connection and tries to connect to the server using the given connection string. The given connection string is parsed and checked for correct parameters. Nil and an error is returned if the connection string had invalid values or a connection to the server could not be established, otherwise, a pointer to the newly established connection is returned.

func New

func New(config SQCloudConfig) *SQCloud

func (*SQCloud) AddNode

func (this *SQCloud) AddNode(Node string, Address string, Cluster string, Snapshot string, Learner bool) error

AddNode - INTERNAL SERVER COMMAND: Adds a node to the SQLite Cloud Database Cluster.

func (*SQCloud) Auth

func (this *SQCloud) Auth(Username string, Password string) error

Auth - INTERNAL SERVER COMMAND: Authenticates User with the given credentials.

func (*SQCloud) AuthWithKey

func (this *SQCloud) AuthWithKey(Key string) error

Auth - INTERNAL SERVER COMMAND: Authenticates User with the given API KEY.

func (*SQCloud) BeginTransaction

func (this *SQCloud) BeginTransaction() error

BeginTransaction starts a transaction. To finish a transaction, see: SQCloud.EndTransaction(), to undo a transaction, see: SQCloud.RollBackTransaction()

func (*SQCloud) CheckConnectionParameter

func (this *SQCloud) CheckConnectionParameter() error

CheckConnectionParameter checks the given connection arguments for validly. Host is either a resolve able hostname or an IP address. Port is an unsigned int number between 1 and 65535. Timeout must be 0 (=no timeout) or a positive number. Compress must be "NO" or "LZ4". Username, Password and Database are ignored. If a given value does not fulfill the above criteria's, an error is returned.

func (*SQCloud) Close

func (this *SQCloud) Close() error

Close closes the connection to the SQLite Cloud Database server. The connection can later be reopened (see: reconnect)

func (*SQCloud) CloseConnection

func (this *SQCloud) CloseConnection(ConnectionID string) error

CloseConnection - INTERNAL SERVER COMMAND: Closes the specified connection.

func (*SQCloud) Compress

func (this *SQCloud) Compress(CompressMode string) error

Compress enabled or disables data compression for this connection. If enabled, the data is compressed with the LZ4 compression algorithm, otherwise no compression is applied the data.

func (*SQCloud) Connect

func (this *SQCloud) Connect() error

Connect connects to a SQLite Cloud server instance using the given arguments. If Connect is called on an already established connection, the old connection is closed first. All arguments are checked for valid values (see: CheckConnectionParameter). invalid argument values where given or the connection could not be established.

func (*SQCloud) CreateChannel

func (this *SQCloud) CreateChannel(Channel string, NoError bool) error

Creates the specified Channel.

func (*SQCloud) CreateDatabase

func (this *SQCloud) CreateDatabase(Database string, Key string, Encoding string, NoError bool) error

CreateDatabase - INTERNAL SERVER COMMAND: Creates a new Database on this SQLite Cloud Database Cluster. If the Database already exists on this Database Server, an error is returned except the NoError flag is set. Encoding specifies the character set Encoding that should be used for the new Database - for example "UFT-8".

func (*SQCloud) DisablePlugin

func (this *SQCloud) DisablePlugin(Plugin string) error

DisablePlugin disables the SQLite Plugin on the SQlite Cloud Database server.

func (*SQCloud) EnablePlugin

func (this *SQCloud) EnablePlugin(Plugin string) error

EnablePlugin enables the SQLite Plugin on the SQlite Cloud Database server.

func (*SQCloud) EndTransaction

func (this *SQCloud) EndTransaction() error

EndTransaction finishes a transaction and writes the changes to the disc. To start a transaction, see: SQCloud.BeginTransaction(), to undo a transaction, see: SQCloud.RollBackTransaction().

func (*SQCloud) Execute

func (this *SQCloud) Execute(SQL string) error

Execute executes the given query. If the execution was not successful, an error describing the reason of the failure is returned.

func (*SQCloud) ExecuteArray

func (this *SQCloud) ExecuteArray(SQL string, values []interface{}) error

func (*SQCloud) GetAutocompleteTokens

func (this *SQCloud) GetAutocompleteTokens() (tokens []string)

func (*SQCloud) GetDatabase

func (this *SQCloud) GetDatabase() (string, error)

GetDatabase - INTERNAL SERVER COMMAND: Gets the name of the previously selected Database as string. (see: *SQCloud.UseDatabase()) If no database was selected, an error describing the problem is returned.

func (*SQCloud) GetError

func (this *SQCloud) GetError() (int, int, int, error)

GetError returned the error code and message of the last unsuccessful command. 0 and nil is returned if the last command run successful.

func (*SQCloud) GetErrorCode

func (this *SQCloud) GetErrorCode() int

GetErrorCode returns the error code of the last unsuccessful command as an int value. 0 is returned if the last command run successful.

func (*SQCloud) GetErrorMessage

func (this *SQCloud) GetErrorMessage() error

GetErrorMessage returns the error message of the last unsuccuessful command as an error. nil is returned if the last command run successful.

func (*SQCloud) GetErrorOffset

func (this *SQCloud) GetErrorOffset() int

GetErrorOffset returns the error code of the last unsuccessful command as an int value. 0 is returned if the last command run successful.

func (*SQCloud) GetExtErrorCode

func (this *SQCloud) GetExtErrorCode() int

GetExtErrorCode returns the error code of the last unsuccessful command as an int value. 0 is returned if the last command run successful.

func (*SQCloud) GetInfo

func (this *SQCloud) GetInfo() (SQCloudInfo, error)

GetInfo fetches all SQLite Cloud Database server specific runtime informations and returns a SQCloudInfo structure.

func (*SQCloud) GetKey

func (this *SQCloud) GetKey(Key string) (string, error)

GetKey gets the Value of the key Key and returns it as a string value. If the Key was not found an error is returned.

func (*SQCloud) GetPAuth

func (this *SQCloud) GetPAuth() (string, string)

PAuth returns the auth details for pubsub

func (*SQCloud) GetUUID

func (this *SQCloud) GetUUID() string

GetUUID returns the UUID as string

func (*SQCloud) IsConnected

func (this *SQCloud) IsConnected() bool

IsConnected checks the connection to the SQLite Cloud database server by sending a PING command. true is returned, if the connection is established and actually working, false otherwise.

func (*SQCloud) IsError

func (this *SQCloud) IsError() bool

IsError checks the successful execution of the last method call / command. true is returned if the last command resulted in an error, false otherwise.

func (*SQCloud) ListChannels

func (this *SQCloud) ListChannels() ([]string, error)

func (*SQCloud) ListClientKeys

func (this *SQCloud) ListClientKeys() (map[string]string, error)

ListClientKeys lists all client/connection specific keys and values and returns the data in an array of type SQCloudKeyValues.

func (*SQCloud) ListColumns

func (this *SQCloud) ListColumns(TableName string) (columns []string)

func (*SQCloud) ListCommands

func (this *SQCloud) ListCommands() ([]string, error)

ListCommands lists all available server commands and returns them in an array of strings.

func (*SQCloud) ListConnections

func (this *SQCloud) ListConnections() ([]SQCloudConnection, error)

ListConnections - INTERNAL SERVER COMMAND: Lists all connections of this SQLite Cloud Database Cluster.

func (*SQCloud) ListDatabaseConnections

func (this *SQCloud) ListDatabaseConnections(Database string) ([]SQCloudConnection, error)

ListDatabaseConnections - INTERNAL SERVER COMMAND: Lists all connections that use the specified Database on this SQLite Cloud Database Cluster.

func (*SQCloud) ListDatabaseKeys

func (this *SQCloud) ListDatabaseKeys(Database string) (map[string]string, error)

ListDatabaseKeys lists all server specific keys and values and returns an array of type SQCloudKeyValues.

func (*SQCloud) ListDatabases

func (this *SQCloud) ListDatabases() ([]string, error)

ListDatabases - INTERNAL SERVER COMMAND: Lists all Databases that are present on this SQLite Cloud Database Cluster and returns the Names of the databases in an array of strings.

func (*SQCloud) ListKeys

func (this *SQCloud) ListKeys() (map[string]string, error)

ListKeys lists all key value pairs on the server and returns an array of SQCloudKeyValues.

func (*SQCloud) ListNodes

func (this *SQCloud) ListNodes() ([]SQCloudNode, error)

RemoveNode - INTERNAL SERVER COMMAND: Lists all nodes of this SQLite Cloud Database Cluster.

func (*SQCloud) ListPlugins

func (this *SQCloud) ListPlugins() ([]SQCloudPlugin, error)

ListPlugins list all available Plugins at the SQlite Cloud Database server and returns an array of SQCloudPlugin.

func (*SQCloud) ListTables

func (this *SQCloud) ListTables() ([]string, error)

ListTables lists all tables in the selected database and returns them in an array of strings. If no database was selected with SQCloud.UseDatabase(), an error is returned.

func (*SQCloud) Listen

func (this *SQCloud) Listen(Channel string) error

Listen subscribes this connection to the specified Channel.

func (*SQCloud) ListenTable

func (this *SQCloud) ListenTable(TableName string, DatabaseName string) error

Listen subscribes this connection to the specified Table.

func (*SQCloud) Notify

func (this *SQCloud) Notify(Channel string) error

Notify sends a wakeup call to the channel Channel

func (*SQCloud) Ping

func (this *SQCloud) Ping() error

Ping sends the PING command to the SQLite Cloud Database Server and returns nil if it got a PONG answer. If no PONG was received or a timeout occurred, an error describing the problem is retuned.

func (*SQCloud) RemoveChannel

func (this *SQCloud) RemoveChannel(Channel string) error

Deletes the specified Channel.

func (*SQCloud) RemoveDatabase

func (this *SQCloud) RemoveDatabase(Database string, NoError bool) error

RemoveDatabase - INTERNAL SERVER COMMAND: Deletes the specified Database on this SQLite Cloud Database Cluster. If the given Database is not present on this Database Server or the user has not the necessary access rights, an error describing the problem will be returned. If the NoError flag is set, no error will be reported if the database does not exist.

func (*SQCloud) RemoveKey

func (this *SQCloud) RemoveKey(Key string) error

RemoveKey deletes the key value pair referenced with Key. If the Key does not exists, no error is returned.

func (*SQCloud) RemoveNode

func (this *SQCloud) RemoveNode(Node string) error

RemoveNode - INTERNAL SERVER COMMAND: Removes a node to the SQLite Cloud Database Cluster.

func (*SQCloud) RollBackTransaction

func (this *SQCloud) RollBackTransaction() error

RollBackTransaction aborts a transaction without the writing the changes to the disc. To start a transaction, see: SQCloud.BeginTransaction(), to finish a transaction, see: SQCloud.EndTransaction().

func (*SQCloud) Select

func (this *SQCloud) Select(SQL string) (*Result, error)

Select executes a query on an open SQLite Cloud database connection. If an error occurs during the execution of the query, nil and an error describing the problem is returned. On successful execution, a pointer to the result is returned.

func (*SQCloud) SelectArray

func (this *SQCloud) SelectArray(SQL string, values []interface{}) (*Result, error)

func (*SQCloud) SelectArrayKeyValues

func (this *SQCloud) SelectArrayKeyValues(SQL string, values []interface{}) (map[string]string, error)

func (*SQCloud) SelectKeyValues

func (this *SQCloud) SelectKeyValues(SQL string) (map[string]string, error)

SelectKeyValues executes the query in SQL and returns the result as an array of SQCloudKeyValues. The given query must result in 0 or more rows and two columns. If no row was selected, an empty array is returned. If less or more than two columns where selected, an empty array and an error describing the problem is returned. In all other cases, an array of SQCloudKeyValues is returned. See: SQCloud.SelectSingleString(), SQCloud.SelectSingleInt64(), SQCloud.SelectStringList()

func (*SQCloud) SelectMap

func (this *SQCloud) SelectMap(SQL string) (map[string]interface{}, error)

func (*SQCloud) SelectSingleInt64

func (this *SQCloud) SelectSingleInt64(SQL string) (int64, error)

SelectSingleInt64 executes the query in SQL and returns the result as int64. The given query must return one single numerical value. If no value, more than one values or a non-numerical value is selected by the query, 0 is returned and error describes the problem that occurred. See: SQCloud.SelectSingleString(), SQCloud.SelectStringList(), SQCloud.SelectKeyValues()

func (*SQCloud) SelectSingleString

func (this *SQCloud) SelectSingleString(SQL string) (string, error)

SelectSingleString executes the query in SQL and returns the result as string. The given query must return one single value. If no value or more than one values are selected by the query, nil is returned and error describes the problem that occurred. See: SQCloud.SelectSingleInt64(), SQCloud.SelectStringList(), SQCloud.SelectKeyValues()

func (*SQCloud) SelectStringList

func (this *SQCloud) SelectStringList(SQL string) ([]string, error)

SelectStringList executes the query in SQL and returns the result as an array of strings. The given query must result in 0 or more rows and one column. If no row was selected, an empty string array is returned. If more than one column was selected, an empty string array and an error describing the problem is returned. In all other cases, an array of strings is returned. See: SQCloud.SelectSingleString(), SQCloud.SelectSingleInt64(), SQCloud.SelectKeyValues()

func (*SQCloud) SelectStringListWithCol

func (this *SQCloud) SelectStringListWithCol(SQL string, col uint64) ([]string, error)

func (*SQCloud) SendBlob

func (this *SQCloud) SendBlob(data []byte) error

func (*SQCloud) SendNotificationMessage

func (this *SQCloud) SendNotificationMessage(Channel string, Message string) error

SendNotificationMessage sends the message Message to the channel Channel

func (*SQCloud) SetKey

func (this *SQCloud) SetKey(Key string, Value string) error

SetKey set the provided key value pair with the key Key to the string value Value.

func (*SQCloud) Unlisten

func (this *SQCloud) Unlisten(Channel string) error

Unlisten unsubsribs this connection from the specified Channel.

func (*SQCloud) UnlistenTable

func (this *SQCloud) UnlistenTable(TableName string, DatabaseName string) error

Unlisten unsubsribs this connection from the specified Table.

func (*SQCloud) UnuseDatabase

func (this *SQCloud) UnuseDatabase() error

UseDatabase - INTERNAL SERVER COMMAND: Releases the actual Database. Any further SQL commands will result in an error before selecting a new Database. (see: *SQCloud.UseDatabase())

func (*SQCloud) UseDatabase

func (this *SQCloud) UseDatabase(Database string) error

UseDatabase - INTERNAL SERVER COMMAND: Selects the specified Database for usage. Only if a database was selected, SQL Commands can be sent to this specific Database. An error is returned if the specified Database was not found or the user has not the necessary access rights to work with this Database.

type SQCloudConfig

type SQCloudConfig struct {
	Host                  string
	Port                  int
	Username              string
	Password              string
	Database              string
	Timeout               time.Duration
	CompressMode          string
	Secure                bool
	TlsInsecureSkipVerify bool
	Pem                   string
	ApiKey                string
	NoBlob                bool // flag to tell the server to not send BLOB columns
	MaxData               int  // value to tell the server to not send columns with more than max_data bytes
	MaxRows               int  // value to control rowset chunks based on the number of rows
	MaxRowset             int  // value to control the maximum allowed size for a rowset
}

func ParseConnectionString

func ParseConnectionString(ConnectionString string) (config *SQCloudConfig, err error)

ParseConnectionString parses the given connection string and returns it's components. An empty string ("") or -1 is returned as the corresponding return value, if a component of the connection string was not present. No plausibility checks are done (see: CheckConnectionParameter). If the connection string could not be parsed, an error is returned.

type SQCloudConnection

type SQCloudConnection struct {
	ClientID       int64
	Address        string
	Username       string
	Database       string
	ConnectionDate time.Time
	LastActivity   time.Time
}

type SQCloudInfo

type SQCloudInfo struct {
	SQLiteVersion    string
	SQCloudVersion   string
	SQCloudBuildDate time.Time
	SQCloudGitHash   string

	ServerTime         time.Time
	ServerCPUs         int
	ServerOS           string
	ServerArchitecture string

	ServicePID         int
	ServiceStart       time.Time
	ServicePort        int
	ServiceNocluster   int
	ServiceNodeID      int
	SericeMultiplexAPI string

	TLS                   string
	TLSConnVersion        string
	TLSConnCipher         string
	TLSConnCipherStrength int
	TLSConnAlpnSelected   string
	TLSConnServername     string
	TLSPeerCertProvided   int
	TLSPeerCertSubject    string
	TLSPeerCertIssuer     string
	TLSPeerCertHash       string
	TLSPeerCertNotBefore  time.Time
	TLSPeerCertNotAfter   time.Time
}

type SQCloudNode

type SQCloudNode struct {
	NodeID           int64
	NodeInterface    string
	ClusterInterface string
	Status           SQCloudNodeStatus
	Progress         SQCloudNodeProgress
	Match            int64
	LastActivity     time.Time
}

type SQCloudNodeProgress

type SQCloudNodeProgress int64
const (
	Probe SQCloudNodeProgress = iota
	Replicate
	Snapshot
	Unknown
)

type SQCloudNodeStatus

type SQCloudNodeStatus int64
const (
	Leader SQCloudNodeStatus = iota
	Follower
	Candidate
	Learner
)

type SQCloudPlugin

type SQCloudPlugin struct {
	Name        string
	Type        string
	Enabled     bool
	Version     string
	Copyright   string
	Description string
}

type Value

type Value struct {
	Type   byte // _ + # : , $ ^ @ -   /// Types that are not in this Buffer: ROWSET, PUBSUB
	Buffer []byte
}

func (*Value) GetBuffer

func (this *Value) GetBuffer() []byte

func (*Value) GetError

func (this *Value) GetError() (int, int, int, string, error)

GetError returns the ErrorCode, ExtErrorCode, ErrorOffset, ErrorMessage and the error object of the receiver

func (*Value) GetFloat32

func (this *Value) GetFloat32() (float32, error)

func (*Value) GetFloat64

func (this *Value) GetFloat64() (float64, error)

func (*Value) GetInt32

func (this *Value) GetInt32() (int32, error)

func (*Value) GetInt64

func (this *Value) GetInt64() (int64, error)

func (*Value) GetLength

func (this *Value) GetLength() uint64

func (*Value) GetSQLDateTime

func (this *Value) GetSQLDateTime() (time.Time, error)

func (*Value) GetString

func (this *Value) GetString() string

func (*Value) GetType

func (this *Value) GetType() byte

func (*Value) IsArray

func (this *Value) IsArray() bool

func (*Value) IsBLOB

func (this *Value) IsBLOB() bool

func (*Value) IsCommand

func (this *Value) IsCommand() bool

func (*Value) IsError

func (this *Value) IsError() bool

func (*Value) IsFloat

func (this *Value) IsFloat() bool

func (*Value) IsInteger

func (this *Value) IsInteger() bool

func (*Value) IsJSON

func (this *Value) IsJSON() bool

func (*Value) IsNULL

func (this *Value) IsNULL() bool

func (*Value) IsOK

func (this *Value) IsOK() bool

func (*Value) IsPSUB

func (this *Value) IsPSUB() bool

func (*Value) IsReconnect

func (this *Value) IsReconnect() bool

func (*Value) IsRowSet

func (this *Value) IsRowSet() bool

func (*Value) IsSet

func (this *Value) IsSet() bool

func (*Value) IsString

func (this *Value) IsString() bool

func (*Value) IsText

func (this *Value) IsText() bool

Notes

Bugs

  • If key is not set, DB returns NULL -> does not work with current implementation

Directories

Path Synopsis
test module

Jump to

Keyboard shortcuts

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