dblib

package module
v0.0.0-...-b779cef Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2023 License: Apache-2.0 Imports: 3 Imported by: 2

README

go-dblib

PkgGoDev Go Report Card REUSE status

Description

go-dblib is a shared library for go-ase and cgo-ase. These are driver-implementations for the database/sql package of Go (golang) to provide access to SAP ASE instances.

SAP ASE is the shorthand for SAP Adaptive Server Enterprise, a relational model database server originally known as Sybase SQL Server.

Requirements

The package go-dblib is a shared library for the driver-implementations of go-ase and cgo-ase. Thus, one of these implementations is required.

Download and Installation

The packages in this repo can be go get and imported as usual.

go get github.com/SAP/go-dblib/<package>

Usage (Example)

By importing go-dblib there are several use-cases. For example, the dsn-package can be used to set up DSN information that is required to connect to the ASE-database by using a connector.

package main

import (
    "database/sql"

    "github.com/SAP/go-dblib/dsn"
    "github.com/SAP/go-ase"
)

func main() {
    d := dsn.NewInfo()
    d.Host = "hostname"
    d.Port = "4901"
    d.Username = "user"
    d.Password = "pass"

    connector, err := ase.NewConnector(*d)
    if err != nil {
        log.Printf("Failed to create connector: %v", err)
        return
    }

    db, err := sql.OpenDB(connector)
    if err != nil {
        log.Printf("Failed to open database: %v", err)
        return
    }
    defer db.Close()

    if err := db.Ping(); if err != nil {
        log.Printf("Failed to ping ASE: %v", err)
    }
}

Unit tests

Unit tests for the packages are included in their respective directories and can be run using go test.

Known Issues

The list of known issues is available here.

How to obtain support

Feel free to open issues for feature requests, bugs, or general feedback here.

Contributing

Any help to improve this library is highly appreciated.

For details on how to contribute please see the contribution file.

License

Copyright (c) 2019-2020 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache License 2.0 except as noted otherwise in the LICENSE file.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValuesToNamedValues

func ValuesToNamedValues(values []driver.Value) []driver.NamedValue

ValuesToNamedValues translates a slice of driver.Values into driver.NamedValues.

Types

type ASEIsolationLevel

type ASEIsolationLevel int

ASEIsolationLevel reflects the ASE isolation levels.

const (
	ASELevelInvalid         ASEIsolationLevel = -1
	ASELevelReadUncommitted ASEIsolationLevel = iota
	ASELevelReadCommitted
	ASELevelRepeatableRead
	ASELevelSerializableRead
)

Valid ASE isolation levels.

func ASEIsolationLevelFromGo

func ASEIsolationLevelFromGo(lvl sql.IsolationLevel) (ASEIsolationLevel, error)

ASEIsolationLevelFromGo take a database/sql.IsolationLevel and returns the relevant isolation level for ASE.

func (ASEIsolationLevel) String

func (lvl ASEIsolationLevel) String() string

String implements the Stringer interface.

func (ASEIsolationLevel) ToGo

ToGo returns the database/sql.IsolationLevel equivalent of the ASE isolation level.

Directories

Path Synopsis
Package asetime is used to convert golang data type duration to defined ASE data type duration and the other way around.
Package asetime is used to convert golang data type duration to defined ASE data type duration and the other way around.
The package asetypes contains code to link, convert, and work with golang and their respective ASE data types.
The package asetypes contains code to link, convert, and work with golang and their respective ASE data types.
Package capability provides abstract structures to keep a history of capabilities and features.
Package capability provides abstract structures to keep a history of capabilities and features.
dsn
The package dsn is a toolbox of functions to fill and format structs from varying sources.
The package dsn is a toolbox of functions to fill and format structs from varying sources.
Package flagslice defines slice types to be used as custom flag types for the flag library.
Package flagslice defines slice types to be used as custom flag types for the flag library.
The package integration contains helpers to setup and teardown database for various connection types, as well as shared code to run the same tests for types and database/sql methods for the cgo and go implementation.
The package integration contains helpers to setup and teardown database for various connection types, as well as shared code to run the same tests for types and database/sql methods for the cgo and go implementation.
The package namepool is used to provide a name pool that contains names that are safe to use by multiple goroutines.
The package namepool is used to provide a name pool that contains names that are safe to use by multiple goroutines.
The package tds (Tabular Data Stream) is used to connect and communicate to a TDS server such as the ASE.
The package tds (Tabular Data Stream) is used to connect and communicate to a TDS server such as the ASE.
The package term contains common code for interactive database clients.
The package term contains common code for interactive database clients.

Jump to

Keyboard shortcuts

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