How to Integrate Streamlit and Teradata Safely

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams pair streamlit and teradata to turn enterprise warehouse data into interactive web apps. Python scripts send SQL queries to the warehouse and render charts for business users. This workflow helps data teams build custom tools fast. Analysts write Python scripts that fetch rows from large tables. Business users filter metrics in a browser without writing SQL. Still, linking a web app to a core warehouse creates security risks. You must manage how the app logs in and reads data. How strea

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 teradata to turn enterprise warehouse data into interactive web apps. Python scripts send SQL queries to the warehouse and render charts for business users.

This workflow helps data teams build custom tools fast. Analysts write Python scripts that fetch rows from large tables. Business users filter metrics in a browser without writing SQL. Still, linking a web app to a core warehouse creates security risks. You must manage how the app logs in and reads data.

How streamlit and teradata share credentials and data

A Python web app needs a driver to talk to the database. The app uses a Python library to open a network session. When a user loads the page, the script runs from top to bottom. It reads login keys from a local file or secret store. Then it opens a session with the warehouse and sends a SQL query.

The warehouse checks the user name and password or directory token. Next, the database checks the role linked to that account. If the role allows read rights, the engine runs the query. It sends the result rows back over the network to the Python server. The server holds the rows in memory and draws tables on the screen.

Every widget click in the browser triggers a fresh script run. Without caching, the app opens a new database session on every click. Teams use session state and cache functions to reuse open links. This setup keeps query counts low and protects warehouse compute resources.

Common security risks with shared app accounts

Many teams use one shared service account for the whole web app. This shortcut creates blind spots in your database audit logs. Every query in the log shows the same service account name. When a slow or broad query runs, you cannot see which user clicked the button.

Broad database roles make this problem much worse. If the app account has write or drop rights, a bug can break production tables. A bad actor could also use a form input to run extra SQL commands. If the account can read all schemas, any app bug exposes sensitive rows.

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

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Local secret files also add risk during app setup. Developers often store warehouse passwords in plain text files on their laptops. If someone pushes that file to a code repo, anyone can read the key. You should never keep raw database passwords inside app folders.

How to scope roles and network paths

Start by creating a dedicated database role just for your web app. Give this role read rights only on the specific views the app needs. Never point the app at raw base tables with full history. Build clean summary views in the warehouse and grant read rights on those views.

Set resource limits on the database profile tied to the app account. Cap the CPU time and spool space that a single query can use. If a user picks a huge date range, the warehouse will stop the runaway query. This rule keeps one busy dashboard from slowing down other warehouse workloads.

Lock down the network path between the app host and the database. Place the Python server in a private subnet with strict firewall rules. Only allow traffic from the app server IP address to reach the database port. Use encrypted transport so network sniffers cannot read passwords or result rows in transit.

You also need a plan for sensitive fields in query results. Tables often hold emails, phone numbers, card numbers, or national IDs. Masking rules rewrite matched fields in results before they reach the browser screen. This step keeps private customer data safe during daily dashboard use.

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 we stop the app from opening too many database sessions?

Use the built-in resource cache in your Python script to hold one shared session pool. Set a clear time limit on cached query data so the app does not query the warehouse on every click.

Should the web app use a personal user account to log in?

No, never put a personal login in an app script. Use a scoped service role with read rights on specific views, or pass individual user identity tokens for per-user audit logs.

How can we protect sensitive customer columns in dashboard tables?

Do not expose raw tables to the web app. Use database views or masking rules that rewrite emails, phone numbers, card numbers, and national IDs in results before the app renders them.

The query runs. The emails stay hidden.