Giter Site home page Giter Site logo

kite-client-sdk's Introduction

Kite Client SDK

Kite Client SDK allows query the data stored in Kite server. We provide both C, Python, Golang and Java interfaces to connect with Kite.

For C, read the filec/xcli.c for usage.

  hdl = kite_submit(host, schema, sql, fragid, fragcnt, &fs, errmsg, errlen);
  if (!hdl) {
    fprintf(stderr, "kite_submit failed. %s", errmsg);
    return 1;
  }

  e = 0;
  while (e == 0) {
    xrg_iter_t *iter = 0;
    e = kite_next_row(hdl, &iter, errmsg, errlen);
    if (e == 0) {
      // data here
      if (iter == NULL) {
        // no more row
        fprintf(stderr, "EOF nrow = %d\n", nrow);
        break;
      }
    } else {
      fprintf(stderr, "error %d nrow = %d\n. (reason = %s)", e, nrow, errmsg);
    }
  }

For Java, read the java/src/main/java/com/vitessedata/kite/sdk/KiteCmd.java for usage.

    KiteConnection kite = null;
    try {
        kite = new KiteConnection();
        kite.host(addr).schema(schemafn).sql(sqlfn).format(new CsvFileSpec()).fragment(0, 2);
        kite.submit();
        XrgIterator iter = null;

        while ((iter = kite.next()) != null) {
            Object[] objs = iter.getValues();
            for (int i = 0; i < objs.length; i++) {
                if (i > 0) {
                    System.out.print("|");
                }
                System.out.print(objs[i].toString());
            }
            System.out.println();
        }
    } catch (IOException ex) {
        System.err.println(ex);
    } finally {
        try {
            if (kite != null) {
                kite.release();
            }
        } catch (IOException ex) {
            ;
        }
    }

For Python,

Install lz4, pandas, numpy package first,

% pip3 install pandas
% pip3 install numpy
% pip3 intall lz4

Install the package

% git clone [email protected]:vderic/kite-client-sdk.git
% cd kite-client-sdk/python
% pip3 install .

For development in Python 3,

        kitecli = kite.KiteClient()
        try:
                kitecli.host(hosts).sql(sql).schema(new_schema).filespec(kite.CsvFileSpec()).fragment(-1, 2).submit()

                while True:
                        iter = kitecli.next_row()
                        if iter is None:
                                break
                        else:
                                print("flag=", iter.flags, ", values=", iter.values)

        except OSError as msg:
                print(msg)
        finally:
                kitecli.close()

For development in Golang, please visit (https://github.com/vderic/kite-client-go)

kite-client-sdk's People

Contributors

vderic avatar cktan avatar

Watchers

 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.