The Simplest Way to Make Databricks and PostgreSQL Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams pair databricks and postgresql to move live app data into analytics jobs. Data engineers pull rows from the database and run big jobs in notebooks. This workflow turns daily customer orders and events into clear business reports. Data scientists also write model scores back into tables for live apps. How databricks and postgresql share data and roles Compute clusters need a clear network path to reach the database server. A job logs in with a database role and asks for specific tables.

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.

Teams pair databricks and postgresql to move live app data into analytics jobs. Data engineers pull rows from the database and run big jobs in notebooks.

This workflow turns daily customer orders and events into clear business reports. Data scientists also write model scores back into tables for live apps.

How databricks and postgresql share data and roles

Compute clusters need a clear network path to reach the database server. A job logs in with a database role and asks for specific tables.

PostgreSQL checks the role rules before it sends any rows back out. You can grant the read rule on a full table or view.

In PostgreSQL, the read rule also works on specific columns of a table. That same read rule also lets a job export table data out.

When many people run jobs, admins set up group roles in the database. Admins grant table rules to the group role instead of single user accounts.

Then, individual database accounts join that group role to get the right access. This setup keeps database rules clean as the analytics team grows over time.

Clusters read the allowed columns and pull the data into memory for analysis. When a job finishes, it can write final numbers back to a target table.

Common risks with shared database accounts

Many teams put one shared database user and password into a workspace secret. Every notebook and scheduled job then uses that exact same login to run.

When a bad query locks a table, database logs only show the shared account. Nobody knows which person or notebook actually ran the slow query that day.

Shared accounts also tend to gain way too many table rules over time. One team needs to read orders, and another team needs to update user rows.

PostgreSQL Access Control + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Soon, that single shared account can read and change almost every production table. Any person with workspace access can then read sensitive data from a notebook.

Database defaults can also expose more rights than an admin might expect. In PostgreSQL, the special PUBLIC role gives rights to every role on the system.

By default, PUBLIC gets the right to log into databases and make temp tables. It also gets the right to run functions and procedures out of the box.

The owner of a database object can take back those default PUBLIC rights. In PostgreSQL 15 and newer, regular users cannot make objects in the public schema.

Older databases or upgraded systems might still let anyone create objects there. Admins fix that old setting by taking the create rule away from PUBLIC.

How to scope access for analytics jobs

Start by splitting human notebook users from automated night jobs in the database. Give your scheduled pipelines their own dedicated database role with strict table rules.

Grant the read rule only on the exact columns that a pipeline needs. Leave out columns that hold emails, phone numbers, card numbers, or national IDs.

If analysts need to query tables with sensitive columns, use data masking rules. Masking rewrites matched fields in query results before the notebook gets the rows.

Keep network paths tight between your compute subnets and your database network. Only allow traffic from known cluster IP ranges to reach the database port.

Review group roles each quarter to drop old rights that jobs no longer use. Clear role rules keep your production database safe while analytics jobs run fast.

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

How can I stop notebooks from reading sensitive columns in PostgreSQL?

Grant the PostgreSQL read rule only on the safe columns of a table. You can also apply data masking so queries return rewritten values for emails or card numbers.

Why do database logs show the same user for every notebook query?

This happens when a workspace uses one shared login for all clusters. Give teams separate database roles or track user identities on each query session.

Should analytics jobs use the default PUBLIC rights in PostgreSQL?

No, admins should revoke default PUBLIC rights on production databases and functions. Grant connect and read rules only to specific group roles made for analytics.

The query runs. The emails stay hidden.