How to Integrate Streamlit and Trino Safely

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams pair streamlit and trino to build live data apps over large tables. The web app sends SQL queries to the query engine and charts the results. This setup lets analysts explore big data sets in a browser. Without tight rules, one web app can expose every linked database at once. You must lock down how the two tools talk to each other. How streamlit and trino share data and roles When a user opens the web app, Python scripts run on the server. Those scripts open a network link to the quer

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 streamlit and trino to build live data apps over large tables. The web app sends SQL queries to the query engine and charts the results.

This setup lets analysts explore big data sets in a browser. Without tight rules, one web app can expose every linked database at once. You must lock down how the two tools talk to each other.

How streamlit and trino share data and roles

When a user opens the web app, Python scripts run on the server. Those scripts open a network link to the query coordinator node. The app logs in with a key, a password, or a token.

Next, the app sends a SQL read query to the coordinator. The coordinator plans the job and asks worker nodes to pull the rows. Workers read the underlying storage and send rows back to the coordinator. Finally, the Python app gets the rows and draws charts on the screen.

In a basic setup, the app uses one static key for all users. The query engine sees the app role instead of the human user. Every person on the web page gets the exact same data rights. If the app role can read payroll tables, every viewer can too.

A safer design passes the viewer identity from the app to the engine. You make users log in to the web app with single sign-on first. Then the app tells the coordinator which human asked for the data. The query engine checks its own role rules before it runs the SQL.

Common risks and how to scope network paths

Shared service accounts cause the biggest security gaps in this stack. Teams often give the app one broad role so queries do not fail. That single role might have rights to drop tables or read secret schemas. If someone steals that key from the app host, they own everything.

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

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Unlogged queries create another blind spot for security teams. When ten people share one app login, the query log shows one name. You cannot tell which viewer ran a heavy or risky query. During an audit, you have no way to trace who saw what.

Raw query results can also leak personal data into the browser. Python apps often cache tables in memory to make charts load fast. If a table holds emails, phone numbers, or card numbers, the cache stores them. Masking rules can rewrite matched fields in results before the app caches them. You can also mask national IDs so raw values do not reach the chart.

To fix these risks, start by shrinking the role you give the app. Create a read-only role that can only see the exact views needed. Never give the web app rights to write or change table schemas. Split sensitive data into separate catalogs that the app role cannot read.

Next, lock down the network path between the app and the coordinator. Put both servers inside a private network and block public traffic. Use TLS encryption on the link so no one can sniff rows in transit. Set query timeouts so a bad chart filter cannot freeze the whole cluster.

Govern statements and responses across databases and APIs

Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev runs beside each supported service as an open-source proxy, a sidecar for your database or API.

First, hoop.dev guardrails block banned queries before they run. Then hoop.dev data masking rewrites matched sensitive values in responses in memory. The audit trail records every statement and verdict per resource. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.

Frequently asked questions

How do I stop the web app from exposing all catalogs?

Assign the app a strict read-only role in your query engine rules. Grant that role rights only to the specific schemas the chart needs.

Should the Python app cache sensitive query results?

No, you should avoid caching tables that hold emails or card numbers. Shared memory caches can leak private rows to other viewers on the app.

How can we track which viewer ran a specific query?

Put single sign-on in front of the web app to get user names. Pass each user identity to the query engine so logs show the person.

The query runs. The emails stay hidden.