Cortex Code with Postgres
Cortex Code is Snowflake's AI-powered development environment for working with data. It understands your schema, writes and explains SQL, builds pipelines, and helps you iterate faster — whether you're working with Snowflake Postgres or connecting to an external PostgreSQL database.
Cortex Code comes in three flavors so you can work wherever you're most productive:
| Version | Best for |
|---|---|
| Cortex Code Desktop | Local IDE experience with full AI agent capabilities |
| Cortex Code in Snowsight | Browser-based, zero-install access from the Snowflake console |
| Cortex Code CLI | Terminal-first workflows, scripting, and CI/CD integration |
Cortex Code Desktop
Cortex Code Desktop is a standalone IDE built on VS Code that connects directly to Snowflake and PostgreSQL databases. It provides a full AI agent that can read your schema, write queries, create pipelines, and execute multi-step tasks.
Key capabilities
- AI agent with full access to your database schema and metadata
- Write, run, and debug SQL against Snowflake Postgres or any external PostgreSQL
- Build Streamlit apps, stored procedures, and data pipelines with AI assistance
- Jupyter notebook support with inline execution
- Git integration for version-controlled workflows
Connecting to Postgres
Cortex Code Desktop connects to Snowflake Postgres instances through your Snowflake account connection. For external PostgreSQL databases (RDS, Aurora, Cloud SQL, self-hosted), connect using standard PostgreSQL connection strings — the AI assistant understands both environments.
Get Cortex Code Desktop
Available for macOS, Windows, and Linux.
Cortex Code in Snowsight
Cortex Code is built into Snowsight — no installation required. Open it from the Snowflake console to get AI-assisted development directly in your browser.
Key capabilities
- Zero install — available in any browser with a Snowflake account
- AI chat for writing and explaining SQL, exploring schema, and building queries
- Direct access to Snowflake Postgres instances in your account
- Notebook and worksheet support with inline results
- Integrated with Snowflake governance and access controls
Connecting to Postgres
In Snowsight, Cortex Code automatically has access to all Snowflake Postgres instances your role can see. Select your Postgres database context and start working — no connection configuration needed.
Access Cortex Code in Snowsight
Log in to your Snowflake account and open Cortex Code from the left navigation.
Cortex Code CLI
The Cortex Code CLI brings AI-assisted development to your terminal. Use it for quick queries, scripting, automation, and integrating AI-powered data work into your existing command-line workflows.
Key capabilities
- Terminal-based AI assistant for Snowflake and PostgreSQL
- Run natural-language queries that generate and execute SQL
- Scriptable for CI/CD pipelines and automation
- Works alongside psql, pg_dump, and other PostgreSQL CLI tools
- Lightweight and fast for ad-hoc exploration
Connecting to Postgres
The CLI connects to Snowflake Postgres through your configured Snowflake connection. For external PostgreSQL instances, use standard connection parameters (host, port, database, user) that you'd pass to any pg client.
Install the Cortex Code CLI
Install via Homebrew, npm, or direct download.
Built-in Postgres Skills
Cortex Code Desktop and CLI include a dedicated snowflake-postgres skill that activates automatically when you work with Postgres. You don't need to install or configure anything — it's available in every session.
What the Postgres skill does
- Instance management — Create, suspend, resume, and resize Snowflake Postgres instances from natural language
- Natural-language queries — Ask questions in plain English and Cortex Code generates and runs the SQL against your Postgres instance
- Health checks (pg_doctor) — Run read-only diagnostics covering cache hit rates, table bloat, vacuum status, connections, locks, blocking queries, long-running queries, unused indexes, and table sizes
- Data movement — Walk through the multi-system configuration (Snowflake SQL, AWS IAM, Postgres SQL) for connecting Postgres to Snowflake Analytics
- Connection management — Stores connections in standard
~/.pg_service.confand~/.pgpassfiles, compatible with psql and all other PostgreSQL clients
Example prompts
"Create a new Postgres instance in us-west-2" "Show me all tables on my_instance" "How many orders were placed this month?" "Run a health check on my_instance" "Set up pg_lake on my_instance with s3://my-bucket/data/" "Reset credentials for my_instance"
Safety guardrails
Write operations (INSERT, UPDATE, DELETE, DROP) require explicit confirmation before execution. Read-only operations like SELECT, DESCRIBE, and health checks run without approval gates.
Billable or security-sensitive operations — creating instances, modifying network policies, or changing storage integrations — also require confirmation.
Working with External PostgreSQL
Cortex Code Desktop and CLI can connect to PostgreSQL databases outside of Snowflake — RDS, Aurora, Cloud SQL, Azure Database for PostgreSQL, or self-hosted instances.
What you get with external Postgres
- AI-assisted SQL writing that understands your schema
- Query explanation and optimization suggestions
- Schema exploration and documentation
- Data exploration and visualization
Connection requirements
- Standard PostgreSQL connection string (host, port, database, credentials)
- Network connectivity from your machine (Desktop or CLI)
- PostgreSQL 14 or later recommended
Working with Snowflake Postgres
When connected to a Snowflake Postgres instance, Cortex Code unlocks additional platform capabilities beyond standard PostgreSQL.
Platform advantages
- Data movement awareness — Cortex Code understands the bridge between your Postgres tables and Snowflake, helping you build cross-platform queries and pipelines
- Cortex AI integration — Use Cortex Code to write and test Cortex LLM functions against your Postgres data
- Unified governance — Access controls and policies are enforced consistently
- Instance management — Create, resize, suspend, and monitor instances through Cortex Code
Example workflow
- Connect Cortex Code to your Snowflake account
- Select your Postgres instance as the active context
- Ask Cortex Code to explore your schema, write queries, or build data pipelines
- Leverage pg_lake to analyze Postgres data at warehouse scale
- Use Cortex AI functions for intelligent processing without data movement
Comparison: Which Version to Use
| Desktop | CLI | Snowsight | |
|---|---|---|---|
| Installation | Download app | Package manager | None (browser) |
| Best for | Full development sessions | Automation, scripting | Quick exploration, collaboration |
| External Postgres | Yes | Yes | No |
| Snowflake Postgres | Yes | Yes | Yes |
| Notebooks | Yes | No | Yes |
| Git integration | Yes | Yes | No |
| Offline capable | Partial (editing only) | No | No |
This content is provided as is, and is not maintained on an ongoing basis. It may be out of date with current Snowflake instances