Snowflake Terminal Client with Table Scrolling and Prefix Support
Project description
Winter - Snowflake Terminal Client
โ๏ธ Winter is a powerful terminal client for Snowflake with advanced table scrolling, prefix support, security controls, and comprehensive query management.
โจ Features
- ๐ Dual Authentication Support - Password authentication or RSA keypair authentication (.p8 private keys)
- ๐ File Browser - Interactive file browser for selecting private key files during setup
- ๐ท๏ธ Table Prefix System - Automatic prefix application to all table references (JOINs, subqueries, CTEs, DML, DDL)
- ๐ Security Controls - Default SELECT-only with configurable permissions and audit logging
- โฐ Connection Timeout - Automatic connection timeout after 5 minutes of inactivity
- ๐ Mandatory Connection - Must run
winter connectbefore executing queries for better security - ๐ Interactive Table Display - Smooth vertical and horizontal scrolling with Rich tables
- ๐ฎ Advanced Scrolling - Arrow keys and WASD navigation without Enter key
- ๐ Data Analysis - Intelligent column formatting and data type detection
- ๐ Export Capabilities - Export to CSV, JSON, and Excel (XLSX) formats
- ๐ Query History - Automatic logging and searchable query history
- โญ Favorites System - Save and manage favorite queries with tags
- ๐ Search Functionality - Search through history and favorites
- ๐ Multi-Environment Support - Support for different environments
- โก High Performance - Optimized for speed and efficiency
๐ Quick Start
# Install Winter
pip install winter
# Run interactive setup wizard
winter setup
# Connect to Snowflake (mandatory before queries)
winter connect
# Execute your first query (default: 10 rows, 5 columns)
winter execute-query "SELECT * FROM users"
# Use interactive table viewer
winter execute-query "SELECT * FROM users" --interactive
# Custom limits
winter execute-query "SELECT * FROM users" --limit 50 --max-columns 8
# View query history
winter history
# Manage favorite queries
winter manage-favorites
๐ฆ Installation
Quick Install (Recommended)
# Clone repository
git clone https://github.com/ilham-fauzi/winter.git
cd winter
# Install Winter (auto-detects OS and installs dependencies)
make install
Alternative Installation Methods
Linux/macOS
chmod +x install.sh
./install.sh
Windows
# Command Prompt
install.bat
# PowerShell
.\install.ps1
Manual Installation
# Install dependencies
pip install snowflake-connector-python cryptography pyyaml rich click inquirer openpyxl pyperclip pynput
# Install Winter
pip install .
Installation Options
- pipx (recommended): Isolated environment
- pip --user: User installation
- pip: System installation
- Development mode: For contributors
For detailed installation instructions, see INSTALL.md.
โ๏ธ Configuration
Winter uses ~/.winter/config.yaml for configuration and supports two authentication methods:
๐ Authentication Methods
1. Password Authentication
account: your_account.snowflakecomputing.com
user: your_username
auth_method: password
password: your_password # Optional: leave empty to prompt each time
warehouse: COMPUTE_WH
database: YOUR_DB
schema: PUBLIC
role: YOUR_ROLE
connection_timeout: 5 # Minutes (or use hours: 0.5 = 30 minutes)
2. RSA Keypair Authentication
account: your_account.snowflakecomputing.com
user: your_username
auth_method: keypair
private_key_path: ~/.snowflake/rsa_key.p8
warehouse: COMPUTE_WH
database: YOUR_DB
schema: PUBLIC
role: YOUR_ROLE
connection_timeout: 5 # Minutes (or use hours: 0.5 = 30 minutes)
๐ Security Configuration
SELECT-Only Enforcement:
- ๐ SELECT-only queries - Only SELECT statements allowed by default
- ๐ก๏ธ Data protection - Prevents accidental data modification
- ๐ Secure by default - No DML/DDL operations allowed
- ๐ Audit logging - All queries are logged for security
๐ File Browser for Private Key Setup
Interactive File Selection:
- ๐ File browser - Navigate directories to find .p8 files
- ๐ Smart navigation - Start from Downloads directory
- ๐ File filtering - Only shows .p8 files and directories
- ๐ File information - Shows file size and details
- โ
Auto-copy - Automatically copies selected file to
~/.winter/rsa_key.p8 - ๐ Manual search - Search for .p8 files in specific directories
Search Options:
- ๐ฅ Downloads directory - Search in Downloads folder
- ๐ฅ๏ธ Desktop directory - Search in Desktop folder
- ๐ Documents directory - Search in Documents folder
- ๐ Home directory - Search in entire home directory
- ๐ Custom directory - Search in user-specified directory
- ๐ Recursive search - Finds .p8 files in subdirectories
Setup Flow:
winter setup
# Choose RSA Keypair Authentication
# Choose "Browse for .p8 file (Recommended)"
# Navigate directories OR type 'search' for manual search
# Select your .p8 file
# File automatically copied to ~/.winter/rsa_key.p8
โฐ Connection Timeout Configuration
Configurable Timeout:
- Minutes:
connection_timeout: 5(5 minutes) - Hours:
connection_timeout: 0.5(30 minutes) - Default: 5 minutes if not specified
Password Caching:
- ๐ Session-based caching - Password cached until disconnect/timeout
- ๐ Secure storage - Password only stored in memory during session
- โก Auto-reconnect - Uses cached password for seamless reconnection
- ๐งน Auto-clear - Password cleared on disconnect or timeout
๐ Security Configuration
table_prefix: "prod_" # Applied to all table references
security:
allowed_all_query_types: false # Default: SELECT-only
audit_logging: true
blocked_schemas: ["SENSITIVE"]
allowed_schemas: ["PUBLIC", "ANALYTICS"]
๐ Usage
Connection Management
# Connect to Snowflake (mandatory before queries)
winter connect
# Test connection
winter test-connection
# Show connection info
winter connection-info
# Disconnect
winter disconnect
โ ๏ธ Important Notes:
- You must run
winter connectbefore executing any queries - Connection automatically times out after 5 minutes of inactivity
- If connection expires, run
winter connectagain to reconnect
Query Execution
# Basic query execution (default: 10 rows, 5 columns)
# Note: Must run 'winter connect' first
winter execute-query "SELECT * FROM users"
# Interactive table viewer with scrolling
winter execute-query "SELECT * FROM users" --interactive
# Limit rows and columns
winter execute-query "SELECT * FROM users" --limit 50 --max-columns 8
# Query with custom prefix
winter execute-query "SELECT * FROM users" --prefix "dev_"
Table Prefix System
The prefix system automatically applies prefixes to all table references:
-- Input query
SELECT u.name, o.total
FROM users u
JOIN orders o ON u.id = o.user_id
-- With prefix "prod_" becomes:
SELECT u.name, o.total
FROM prod_users u
JOIN prod_orders o ON u.id = o.user_id
Prefix Rules:
- โ
Applied to:
FROM,JOIN,UPDATE,INSERT INTO,DELETE FROM,TRUNCATE TABLE - โ Applied to: Subqueries, CTEs, DML, DDL statements
- โ Not applied to: Schema-qualified tables (
schema.table) - โ Not applied to: Database-qualified tables (
db.schema.table) - โ Not applied to: Aliased tables (preserves original alias format)
Interactive Table Viewer
# Enable interactive mode
winter execute-query "SELECT * FROM large_table" --interactive
# Navigation controls:
# โ/โ : Scroll horizontally OR smart pagination
# โ/โ : Scroll vertically (up/down)
# WASD : Alternative navigation (W=up, A=left, S=down, D=right)
# i : Show column information and data types
# q : Quit interactive mode
# h : Show help
# Smart Pagination:
# โ at last columns = Next page of data
# โ at first columns = Previous page of data
Export Functionality
# Export to single format
winter export-query "SELECT * FROM users" --format csv
winter export-query "SELECT * FROM users" --format json
winter export-query "SELECT * FROM users" --format xlsx
# Export with custom filename
winter export-query "SELECT * FROM users" --format csv --output "my_data"
# Export to multiple formats
winter export-all "SELECT * FROM users"
# Export with row limit
winter export-query "SELECT * FROM users" --limit 1000
Query History & Favorites
# View query history
winter history
winter history --limit 50
# Search query history
winter search-history "users"
winter search-history "JOIN"
# View favorite queries
winter favorites
# Add favorite query
winter add-favorite "user_summary" "SELECT id, name, email FROM users" --description "User summary query" --tags "users,summary"
# Search favorites
winter search-favorites "users"
# Delete favorite
winter delete-favorite 1
# Interactive favorite manager
winter manage-favorites
Security Management
# Check security status
winter security-status
# View audit log
winter audit-log
# Test security controls
winter security-test
# Configure security settings
winter security-config
Connection Management
# Test connection
winter test-connection
# Show connection info
winter connection-info
# Connect to Snowflake
winter connect
# Disconnect
winter disconnect
Query Analysis
# Parse and analyze query
winter parse-query "SELECT * FROM users u JOIN orders o ON u.id = o.user_id"
# Validate query
winter validate-query "SELECT * FROM users"
# Show query summary
winter query-summary "SELECT * FROM users"
๐ฎ Interactive Controls
Table Navigation
- Arrow Keys: Navigate without Enter key
- WASD: Alternative navigation
- Mouse Wheel: Scroll in terminal
- Column Info: Press
ito see data types and statistics - Help: Press
hfor help
Data Display
- Consistent Column Widths: Prevents header "heaping"
- Intelligent Formatting: Automatic data type detection
- Color Coding: Different colors for different data types
- Truncation: Long values are truncated with ellipsis
๐ Data Types Supported
- ๐ DateTime: Cyan color, formatted display
- ๐ Date: Green color, formatted display
- ๐ข Integer: Magenta color, right-aligned
- ๐ฐ Decimal: Yellow color, formatted numbers
- โ Boolean: Blue color, true/false display
- ๐ Text: White color, standard display
๐ง Advanced Features
Column Analysis
- Automatic data type detection
- Null value counting
- Unique value analysis
- Sample value display
- Optimal column width suggestions
Export Formats
- CSV: Standard comma-separated values
- JSON: Structured JSON with metadata
- Excel (XLSX): Full Excel format with formatting
Security Features
- Query type validation (SELECT-only by default)
- Schema access control
- Audit logging
- Session management
- Dangerous function blocking
๐ File Structure
winter/
โโโ __init__.py
โโโ main.py # CLI entry point
โโโ cli/ # CLI components
โโโ snowflake/ # Snowflake connection
โโโ query/ # Query processing and prefix system
โโโ security/ # Security controls
โโโ ui/ # Interactive table viewer
โโโ formatters/ # Data formatting and analysis
โโโ export/ # Export functionality
โโโ history/ # Query history and favorites
โโโ setup/ # Setup wizard
โโโ utils/ # Utility functions
๐ ๏ธ Development
Running Locally
# From project root
python3 run_winter.py execute-query "SELECT 1"
# Or install in development mode
pip install -e .
winter execute-query "SELECT 1"
Testing
# Run all tests
python3 test_winter.py
# Run specific test modules
python3 -m pytest tests/test_query.py
python3 -m pytest tests/test_snowflake.py
Requirements
- Python: 3.8+
- Dependencies:
snowflake-connector-python>=3.0.0cryptography>=3.4.8pyyaml>=6.0rich>=13.0.0click>=8.0.0inquirer>=3.0.0pandas>=1.5.0openpyxl>=3.0.0
๐ Security
- RSA Keypair Authentication: Secure .p8 key authentication
- SELECT-only by Default: Prevents accidental data modification
- Schema Access Control: Block or allow specific schemas
- Audit Logging: Track all query executions
- Session Management: Secure session handling
๐ Examples
Complex Query with Prefixes
-- Input
WITH user_stats AS (
SELECT u.id, COUNT(o.id) as order_count
FROM users u
LEFT JOIN orders o ON u.id = o.user_id
GROUP BY u.id
)
SELECT us.*, u.name
FROM user_stats us
JOIN users u ON us.id = u.id
WHERE us.order_count > 5
-- With prefix "prod_" becomes:
WITH user_stats AS (
SELECT u.id, COUNT(o.id) as order_count
FROM prod_users u
LEFT JOIN prod_orders o ON u.id = o.user_id
GROUP BY u.id
)
SELECT us.*, u.name
FROM user_stats us
JOIN prod_users u ON us.id = u.id
WHERE us.order_count > 5
Interactive Table Usage
# Start interactive session
winter execute-query "SELECT * FROM large_table" --interactive
# Navigate with arrow keys
# Press 'i' to see column information
# Press 'h' for help
# Press 'q' to quit
๐ค Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
๐ License
MIT License - see LICENSE file for details
๐ Support
- Issues: GitHub Issues
- Documentation: Wiki
- Discussions: GitHub Discussions
๐ฏ Roadmap
- Query result caching
- Advanced query templates
- Multi-database support
- Query performance analysis
- Custom themes and styling
- Plugin system for extensions
Winter - Making Snowflake terminal access powerful and intuitive! โ๏ธ
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file winter_snowflake-0.1.0.tar.gz.
File metadata
- Download URL: winter_snowflake-0.1.0.tar.gz
- Upload date:
- Size: 79.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d12215eb4dc785e90b266c7514b4b5de279b8f372a6f8a512981b758418b6ab3
|
|
| MD5 |
540259d6fff46ff27ee0db4b5224f17f
|
|
| BLAKE2b-256 |
6b4f9b45a059681b65fc595140ca11df9de5b59887cff944fabb001fba04e48a
|
File details
Details for the file winter_snowflake-0.1.0-py3-none-any.whl.
File metadata
- Download URL: winter_snowflake-0.1.0-py3-none-any.whl
- Upload date:
- Size: 54.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ec7b9de42d941b9de95da957daa04857b04d7506c331d3ac66d5717e751851d
|
|
| MD5 |
8773459711bb0478e70d96a5f95d966d
|
|
| BLAKE2b-256 |
8d9115b4358d28d80d524f70a11abfd31001e14e5deec1dfdd03d84bc5ec1d11
|