Apache Kylin Python Client Library is a python-based Apache Kylin client. There are two components in Apache Kylin Python Client Library:
You can get more detail from this Github Repository.
Make sure Python version is 2.7+ or 3.4+. The easiest way to install Apache Kylin Python Client Library is to use “pip”:
pip install --upgrade kylinpy
After installing Apache Kylin Python Client Library you may run kylinpy in terminal.
$ kylinpy Usage: kylinpy [OPTIONS] COMMAND [ARGS]... Options: -h, --host TEXT Kylin host name [required] -P, --port INTEGER Kylin port, default: 7070 -u, --username TEXT Kylin username [required] -p, --password TEXT Kylin password [required] --project TEXT Kylin project [required] --prefix TEXT Kylin RESTful prefix of url, default: "/kylin/api" --debug / --no-debug show debug information --help Show this message and exit. Commands: auth get user auth info cube_columns list cube columns cube_desc show cube description cube_names list cube names model_desc show model description projects list all projects query sql query table_columns list table columns table_names list all table names
kylinpy -h hostname -P 7070 -u ADMIN -p KYLIN --project learn_kylin --debug auth
kylinpy -h hostname -P 7070 -u ADMIN -p KYLIN --project learn_kylin --debug cube_columns --name kylin_sales_cube
kylinpy -h hostname -P 7070 -u ADMIN -p KYLIN --project learn_kylin --debug cube_desc --name kylin_sales_cube
kylinpy -h hostname -u ADMIN -p KYLIN --project learn_kylin --debug cube_names
kylinpy -h hostname -P 7070 -u ADMIN -p KYLIN --project learn_kylin --debug cube_sql --name kylin_sales_cube
kylinpy -h hostname -P 7070 -u ADMIN -p KYLIN --project learn_kylin --debug projects
kylinpy -h hostname -P 7070 -u ADMIN -p KYLIN --project learn_kylin --debug table_columns --name KYLIN_SALES
kylinpy -h hostname -u ADMIN -p KYLIN --project learn_kylin --api1 table_names
kylinpy -h hostname -P 7070 -u ADMIN -p KYLIN --project learn_kylin --debug model_desc --name kylin_sales_model
Any application that uses SQLAlchemy can now query Apache Kylin with this Apache Kylin dialect installed. It is part of the Apache Kylin Python Client Library, so if you already installed this library in the previous step, you are ready to use. You may use below template to build DSN to connect Apache Kylin.
kylin://<username>:<password>@<hostname>:<port>/<project>?version=<v1|v2>&prefix=</kylin/api>
Test connection with Apache Kylin
$ python
>>> import sqlalchemy as sa
>>> kylin_engine = sa.create_engine('kylin://username:password@hostname:7070/learn_kylin?version=v1')
>>> results = kylin_engine.execute('SELECT count(*) FROM KYLIN_SALES')
>>> [e for e in results]
[(4953,)]
>>> kylin_engine.table_names()
[u'KYLIN_ACCOUNT',
u'KYLIN_CAL_DT',
u'KYLIN_CATEGORY_GROUPINGS',
u'KYLIN_COUNTRY',
u'KYLIN_SALES',
u'KYLIN_STREAMING_TABLE']
Please refer to the blog Use Python for Data Science with Apache Kylin.