How to Integrate Hex and Cloud SQL Safely

Published
Length
3 min read

Luis Felipe Dias

All posts

Integrating hex and cloud sql lets teams run shared data notebooks on live databases. Analysts query tables, build charts, and share reports in one workspace. This setup brings speed to data teams, but it also creates security risks. You must lock down database roles and network paths before you run queries. How hex and cloud sql work together Hex serves as a shared workspace where analysts write queries and Python scripts. Cloud SQL runs your managed database instance in Google Cloud. When

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

Integrating hex and cloud sql lets teams run shared data notebooks on live databases. Analysts query tables, build charts, and share reports in one workspace.

This setup brings speed to data teams, but it also creates security risks. You must lock down database roles and network paths before you run queries.

How hex and cloud sql work together

Hex serves as a shared workspace where analysts write queries and Python scripts. Cloud SQL runs your managed database instance in Google Cloud.

When a user runs a notebook cell, Hex sends a query over the network. The database checks the login details and runs the query against the requested tables.

Cloud SQL for PostgreSQL is a managed service with specific role limits. Customers do not get accounts with full superuser status on the instance.

A Google system account holds the top privileges on the database instead. Customers cannot delete or change these built-in system roles.

The default admin user comes with role creation, database creation, and login rights. It does not hold superuser or replication rights on the instance.

You must set a password for this default admin user before logging in. Still, you should never put that admin login into an analytics workspace.

Common failure modes with shared database logins

Many teams put one shared database account into their notebook workspace for everyone. That single login often has broad rights to read and write production tables.

If an analyst runs a bad update query, it can break production data. Worse, database logs will only show the shared account name, not the person.

End-to-End Encryption + SQL Query Filtering: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

You lose the ability to see which team member ran a specific query. Audits become hard when ten people share one static database password.

Another common mistake is using the Cloud SQL admin role for reporting tools. That role can create extensions, event triggers, and replication users across the instance.

Analytics tools never need those powers to build charts or run basic reports. You should create a dedicated read-only user for your notebook queries instead.

Grant that user read rights only on the specific schemas needed for analysis. Leave sensitive tables out of its reach by default.

Scoping network paths and protecting sensitive fields

Network rules are just as important as database role permissions in production. Never open your database instance to all public internet traffic for easy access.

Restrict incoming traffic to approved IP addresses or route it through private networks. Encrypted connections must be required so data stays safe while moving across networks.

Even with read-only roles, production tables often hold raw personal details. Analysts querying user tables might pull emails, phone numbers, card numbers, or national IDs.

Exposing these fields in shared notebooks increases the risk of a data leak. Data masking helps by rewriting matched fields in query results before notebooks load them.

This way, teams can still count rows and join tables without exposing raw secrets. Strong role limits, strict network rules, and field masking keep your data safe.

Add runtime guardrails and masking beside your databases and APIs

Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits beside the service as an open-source proxy, a sidecar for your database or API.

Before a query runs, hoop.dev guardrails check the statement against your rules. An AI Analyzer you configure can score intent or hold risky calls for human review. Next, hoop.dev data masking rewrites sensitive fields in responses, and each verdict is logged per listener. Explore the MIT-licensed project on GitHub.

Frequently asked questions

No, the default admin user has broad rights to create databases and roles. Always create a separate user with read-only permissions on specific schemas for analytics.

Why are shared service accounts risky for notebook tools?

Shared accounts hide individual user actions inside your database logs. When everyone uses one login, you cannot tell who ran an expensive or harmful query.

How can teams protect sensitive columns during notebook analysis?

Teams can restrict access to specific tables using database roles and views. They can also apply data masking to rewrite emails, phone numbers, and card numbers in results.

The query runs. The emails stay hidden.