Getting Started
Let's discover Defog in less than 5 minutes. Here's a 1-minute demo of the setup
What you'll need
- A Defog API Key. Sign up here for a free API key
- Python 3
- Pip
- Drivers for your database
If you do not have pip
installed on your computer, you can install it here
Initializing Defog
Get started by install our CLI interface.
To do this, just run the following commands on your terminal
pip install --upgrade 'defog[snowflake]'
# If you're not using Snowflake, then you can replace the above with
# pip install --upgrade 'defog[postgres]' or pip install --upgrade 'defog[mysql]' or pip install --upgrade 'defog[bigquery]'
defog init
From here, you can just follow the instructions in the CLI wizard to get started!
Important Note: Doing this does not send your database credentials to Defog! This is only done so we can get your database metadata (table names, column names, column descriptions), and so you can execute the queries generated by Defog locally on your machine.
Generating a CSV file for your metadata
To generate a CSV file that contains your metadata, just list all the tables names you want, separated by a space.
defog gen <table1> <table2> <table3> ...
Once generated, you can edit the CSV to give an accurate description of your metadata. We have included steps to do that in this Cookbook.
Uploading your metadata
To upload your metadata to Defog, just pass in the path to your CSV via defog update
defog update path_to_metadata_csv
For example, if your CSV is in the current folder as defog_metadata.csv
, you should just run defog update defog_metadata.csv
Making a test query
One your metadata has been updated, you can start making test queries. An example query is below
defog query 'how many users do we have?'
(Optional) Deploying to AWS Lambda or GCP Functions
If you want to deploy Defog a a microservice on your cloud, you can run the following functions:
# for AWS Lambda
# before this, you must install chalice with `pip install chalice`
defog deploy aws
# for GCP Functions
# before this, you must have gcloud installed on your machine
defog deploy gcp
Once you do this, you will see the API endpoint for your microservice in your console