Code Monkey home page Code Monkey logo

avatica's Introduction

Apache Phoenix/Avatica SQL Driver

GoDoc wercker status Coverage Status

An Apache Phoenix/Avatica driver for Go's database/sql package

Getting started

Install using the go tool or your dependency management tool:

$ go get github.com/Boostport/avatica

Usage

The Phoenix/Avatica driver implements Go's database/sql/driver interface, so, import Go's database/sql package and the driver:

import "database/sql"
import _ "github.com/Boostport/avatica"

db, err := sql.Open("avatica", "http://localhost:8765")

Then simply use the database connection to query some data, for example:

rows := db.Query("SELECT COUNT(*) FROM test")

DSN (Data Source Name)

The DSN has the following format (optional parts are marked by square brackets):

http://address:ports[?parameter1=value&...parameterN=value]

In other words, the scheme (http), address and port is mandatory, but the parameters are optional.

The following parameters are supported:

location

The location will be set as the location of unserialized time.Time values. It must be a valid timezone. If you want to use the local timezone, use Local. By default, this is set to UTC.

maxRowCount

The maxRowCount sets the number of rows to fetch from the avatica server. Setting a high number causes avatica to return a large number of rows and setting a low number will cause avatica to return a small amount of rows and fetch more from the server if required. By default, this is set to 100.

time.Time support

The following Phoenix/Avatica datatypes are automatically converted to and from time.Time: TIME, DATE and TIMESTAMP.

It is important to understand that avatica and the underlying database ignores the timezone. If you save a time.Time to the database, the timezone is ignored and vice-versa. This is why you need to make sure the location parameter in your DSN is set to the same value as the location of the time.Time values you are inserting into the database.

We recommend using UTC, which is the default value of location.

Development

To run tests, but skip tests in the vendor directory, run:

go test $(go list ./... | grep -v /vendor/)

The driver is not feature-complete yet, so contributions are very appreciated.

Updating protocol buffer definitions

To update the procotol buffer definitions, update CALCITE_VER in gen-protobuf.bat and gen-protobuf.sh to match the version included by Phoenix and then run the appropriate script for your platform.

About the moby.yml file

The moby.yml file is used by our internal tool to automatically reload and test the code during development. We hope to have this tool open-sourced soon.

License

The driver is licensed under the Apache 2 license.

avatica's People

Contributors

f21 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.