Snowflake in terminal

·

1 min read

  1. Install snowsql - command line client for Snowflake

  2. Install pspg - postgresql pager for viewing tables

  3. Configure snowsql in ~/.snowsql/config:

     [connections.MySnowflake]
     accountname=
     username=
     password=
     database=
     role=
     warehouse=
    
     ...
    
     output_format = psql
     output_file = ~/.snowsql.output
     editor = nvim
     wrap = False
     prompt_format = '''[#FFFF00]+--------------------------------------------------------------------------------------------------------+
     [#FFFF00]| [#FFFFFF]user: [#FFFF00][user] |[#FFFFFF] role: [#FFFF00][role] |[#FFFFFF] warehouse: [#FFFF00][warehouse] |[#FFFFFF] database: [#FFFF00][database]
     [#FFFF00]+--------------------------------------------------------------------------------------------------------+
     [#00FF00]❄❯ '''
    
     ...
    
  4. Optionally configure pspg in ~/.config/pspg/config:

     ...
     theme = 13
     ...
    
  5. Create a snowview alias and PSPG_CONF env var in your~/.zshrc or similar:

     export PSPG_CONF=~/.config/pspg/config
     alias snowvew="truncate -s 0 ~/.snowsql.output && pspg ~/.snowsql.output --stream"
    
  6. In the top terminal window run snowsql:

     snowsql -c MySnowflake
    
  7. In the bottom terminal run snowview:

     snowview
    
  8. Enjoy editing queries in vim using !edit snowsql command in the top terminal and displaying results nicely in the bottom terminal: