# Using Apache Phoenix

> Apache Phoenix lets you use SQL with HBase via JDBC. Use bundled psql.py or sqlline.py for table creation and querying, no separate installation needed.

Apache Phoenix allows you to interact with HBase using a familiar SQL-syntax via a JDBC driver. The Phoenix dependencies are bundled with the Stackable HBase image and do not need to be installed separately (client components need to ensure that they have the correct client-side libraries available). Information about client-side installation can be found [here](https://phoenix.apache.org/docs/installation).

Apache Phoenix comes bundled with a few simple scripts to verify a correct server-side installation. For example, assuming that Phoenix dependencies have been installed to their default location of `/stackable/phoenix/bin`, we can issue the following using the supplied `psql.py` script:

```shell
$ /stackable/phoenix/bin/psql.py  && \
   /stackable/phoenix/examples/WEB_STAT.sql && \
   /stackable/phoenix/examples/WEB_STAT.csv  && \
   /stackable/phoenix/examples/WEB_STAT_QUERIES.sql
```

This script creates, populates and queries a Phoenix table called `WEB_STAT`. Alternatively, one can use the `sqlline.py` script (which wraps the [sqlline](https://github.com/julianhyde/sqlline) utility):

```shell
$ /stackable/phoenix/bin/sqlline.py [zookeeper] [sql file]
```

`sqlline.py` provides an SQL prompt where you can work Phoenix tables interactively. So, to query the table that was created in the previous step, start the script and enter some SQL at the prompt:

![Phoenix Sqlline](https://docs.stackable.tech/home/stable/hbase/_images/phoenix_sqlline.png)

The Phoenix table `WEB_STAT` is created as an HBase table, and can be viewed normally from within the HBase UI:

![Phoenix Tables](https://docs.stackable.tech/home/stable/hbase/_images/phoenix_tables.png)

The `SYSTEM`\* tables are those required by Phoenix and are created the first time that Phoenix is invoked.

> **Note:** Both `psql.py` and `sqlline.py` use the Java client library for Phoenix and spawn a new `java` process in the background. The Zookeeper quorum does not need to be supplied as part of the URL used by the JDBC connection string, as long as the environment variable `HBASE_CONF_DIR` is set and supplied as an element for the `-cp` classpath search: the cluster information is then extracted from `$HBASE_CONF_DIR/hbase-site.xml`.
