How to Integrate Hex and Spanner Safely

Published
Length
3 min read

Luis Felipe Dias

All posts

Integrating hex and spanner lets data teams query relational data inside interactive notebooks. This workflow turns live database rows into charts, models, and reports for your team. Data analysts often need fresh production data to answer hard business questions. Moving data through slow pipelines delays those answers by hours or days. A direct link between your workspace and database fixes this lag. Still, direct links bring security risks if you set them up poorly. How data flows between h

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 spanner lets data teams query relational data inside interactive notebooks. This workflow turns live database rows into charts, models, and reports for your team.

Data analysts often need fresh production data to answer hard business questions. Moving data through slow pipelines delays those answers by hours or days. A direct link between your workspace and database fixes this lag. Still, direct links bring security risks if you set them up poorly.

How data flows between hex and spanner

Your analytics workspace talks to Google Cloud using a service account role. An admin creates a cloud role and grants it read rights on the database. The workspace holds the credentials and sends SQL queries over an encrypted network path. The database runs the query and sends rows back to the notebook memory.

Analysts can then join those database results with local files or Python frames. Each notebook cell runs a fresh query or pulls from a saved cache. When a team publishes a dashboard, the app runs those same queries on a schedule. Every viewer sees updated charts that use the workspace service account permissions.

Google Cloud checks the cloud role before the database reads any table. If the role lacks read permissions for a table, the query fails fast. You can also use SQL dialect settings that match your database setup. Both standard SQL and PostgreSQL interfaces work well for analytical read tasks.

Common failure modes with shared service accounts

Most teams start by giving one shared service account to the whole workspace. This shortcut creates major blind spots for security and platform engineers. When ten analysts run queries through one account, database logs show one identity. You cannot tell which user ran an expensive query or pulled customer tables.

Broad database roles make this problem much worse for your production data. If the shared role has write permissions, a bad script can alter live records. Even read access to all tables exposes sensitive columns like emails and phone numbers. A shared notebook might display card numbers or national IDs in saved chart states.

End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Long-lived JSON keys also create a high risk of credential leaks. Someone might download a key file and leave it on a laptop. If an attacker finds that key, they gain direct network entry to your data. Rotating these static keys takes manual work and often breaks scheduled notebook runs.

Scoping roles and network paths for safer analytics

Start by creating a dedicated cloud role just for analytical read workloads. Grant this role select permissions only on the specific tables analysts need. Never give the notebook role rights to drop tables, change schemas, or write rows. If a table holds secret keys or passwords, block it from this role.

Use fine-grained access controls inside the database to limit table and column visibility. You can create read-only SQL views that leave out emails and card numbers. Grant the workspace role access to those clean views instead of the base tables. Data masking rules can also rewrite phone numbers and national IDs in results.

Lock down the network path between the notebook servers and your cloud project. Restrict traffic by allowing only the static IP addresses used by the notebook service. Set up query timeouts and CPU limits so big notebook joins do not hurt production. Review cloud audit logs each week to spot strange query patterns or large exports.

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

Can notebooks run write queries against the database?

Yes, if the cloud role allows mutations, notebooks can change data. You should always assign a read-only role to block accidental writes.

How do we keep sensitive data out of shared notebooks?

Expose limited SQL views or apply masking rules that rewrite emails and phone numbers. This changes sensitive fields in query results before data reaches the notebook.

How can we prevent notebook queries from slowing down production?

Use database priority settings to run analytical queries at a lower CPU priority. You can also set query timeouts and limit who can run uncached queries.

The query runs. The emails stay hidden.