Quickstart

Attention

Hashquery is currently in public preview. Here are some caveats to keep in mind for early adopters:

  • Backwards compatibility may not be preserved between version upgrades, and you may need to update your package regularly.

  • There may be differences in the SQL logic generated by hashquery compared to the Hashboard app.

  • You may encounter dialect-specific SQL syntax errors or other unexpected errors. If you come across one, let us know by reporting an issue.

Installation

Install Hashquery with pip from PyPI:

$ pip install hashquery

Hashquery requires Python version 3.6 or above.

Using the demo project

The quickest way to give Hashquery a spin is to use our demo project. Add this to your package imports:

from hashquery.demo import demo_project as project

Verify everything’s working by starting a python shell and running one of the demo models:

python
>>> from hashquery.demo import demo_project as project
>>> project.models.products.limit(5).run().df
                     id pizza_size pizza_shape  pizza_type  price
0  14278024243148112051      Large       Round      Custom  13.20
1   9154428932967574098     Medium       Round      Custom  11.00
2   2699960497371169210      Large      Square  Margherita  11.52
3  12910763551309720704     Medium       Round  Margherita   8.00
4   1363512534661457390     Medium      Square      Veggie  13.20

If all looks good, you’re ready to move on to your first analysis.

Connecting to your data

To get started using Hashquery with your own data, you’ll be creating a Hashboard project and configuring it with your database credentials or uploading a CSV/parquet file.

If you already have a Hashboard project, see Authenticating with Hashboard for more detail on on how to connect Hashquery to your existing project.

  1. Open the Hashboard homepage, click “Start for free”, and follow the instructions to configure your project.

  2. After logging in, go to the Data sources page and click + Add connection

  3. Follow the prompts to configure your data source. (If you need help, take a look at the Hashboard documentation).

  4. Install the Hashboard CLI and generate an authentication token for your local environment:

$ pip install hashboard-cli
$ hb token

Alternatively, you can set an API token as an environment variable. See Authenticating with Hashboard for more detail.

  1. Verify everything is hooked up correctly by copy-pasting the following into a new Python file, quickstart.py:

    from hashquery import *
    print(project)
    

    Run the file. If all went smoothly, you should see an index of your project’s contents.

    $ python quickstart.py
    Project: c-AlwxJ0wk123ab on https://hashboard.com
    Models:
    Metrics:
    Connections: uploads
    

You’re all set! You’re ready to start running Hashquery models that read from your data connection, as demonstrated in Your first analysis.

You can also build a Model or Metric in Hashboard UI (docs here) and then import it into your Hashquery script.