# snowflake-queries

Suggestion, use snowsql command-line client

Install snowsql https://docs.snowflake.net/manuals/user-guide/snowsql-install-config.html

On a mac, set an alias in your bash profile
```bash
alias snowsql=/Applications/SnowSQL.app/Contents/MacOS/snowsql
```

Put config in snowsql config file: https://docs.snowflake.net/manuals/user-guide/snowsql-config.html#snowsql-config-file set defaults.

```
accountname = orchard
username = <snowflake username>
password = <snowflake password>
```

Some scripts use variable substitution, so in the same config file in the `[options]` section add:
```
[options]
variable_substitution = true
```

Note: you will be required to 2fa when you use the cli! If you're going to run multiple queries, open a session and then source scripts, e.g.
```
$ snowsql
(Do MFA auth)
pinfieldharm#DEV_OWS_WAREHOUSE@(no database).(no schema)> !source vector_status.sql
pinfieldharm#DEV_OWS_WAREHOUSE@(no database).(no schema)> !exit
```

Depending on what you're doing, various output formats are useful: https://docs.snowflake.net/manuals/user-guide/snowsql-config.html#output-format

To set a variable on the command line:
```
snowsql -D somevar=somevalue
```
