What you'll achieve
By the end of this tutorial, you'll be able to use Spectacles to check the validity of the SQL defined in the dimensions of your Looker project.
Set up a local environment
We recommend creating a separate folder and Python virtual environment for Spectacles.
If you already have a preferred approach for creating a Python virtual environment, you can skip this step!
- Create a folder called
- Create a Python virtual environment for Spectacles. If you don't already have a preferred way of doing this, we recommend pyenv-virtualenv. Follow the instructions to install pyenv and pyenv-virtualenv. Then, from your
spectaclesfolder, run the following:
Once you've created and activated your virtual environment, run the following to install Spectacles:
Create an API key in Looker
If you already have a Looker API key and know where to find it in Looker, you can skip this step!
- From Looker, go to Admin > Users.
- Find your user, click Edit, then under API3 Keys click Edit Keys.
- Generate a new API key by clicking New API Key.
Set up a config file
spectacles folder, create a file named
config.yaml with the following contents:
Spectacles will use this config file so you don't have to type out these parameters every time.
Test Spectacles connection to Looker
Once you've saved your credentials to file, test the connection to Looker by running the following:
If the connection test is successful, you should see a message confirming your API and Looker instance version.
Run the SQL Validator
You're ready for the final step! To run the SQL Validator, you'll need:
- The name of your Looker project
- A model and explore to test
What's the name of my Looker project?
Projects are listed at the bottom of the Develop menu in Looker.
Replace your project name, model name, and explore name (separated by a
/) below, then run this command to launch the SQL Validator.
If your explore is free of SQL errors, you'll see something that looks like this.
Congratulations! If Spectacles identified any SQL errors in your explore, try fixing them and re-running the validator.