File: avatica.go

package info (click to toggle)
usql 0.19.19-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,652 kB
  • sloc: sql: 1,115; sh: 643; ansic: 191; makefile: 60
file content (25 lines) | stat: -rw-r--r-- 637 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Package avatica defines and registers usql's Apache Avatica driver.
//
// See: https://github.com/apache/calcite-avatica-go
package avatica

import (
	"strconv"

	_ "github.com/apache/calcite-avatica-go/v5" // DRIVER
	avaticaerrors "github.com/apache/calcite-avatica-go/v5/errors"
	"github.com/xo/usql/drivers"
)

func init() {
	drivers.Register("avatica", drivers.Driver{
		AllowMultilineComments: true,
		AllowCComments:         true,
		Err: func(err error) (string, string) {
			if e, ok := err.(avaticaerrors.ResponseError); ok {
				return strconv.Itoa(int(e.ErrorCode)), e.ErrorMessage
			}
			return "", err.Error()
		},
	})
}