tutorial

How to Create an Internal Tool with Retool and PostgreSQL

A tutorial for building a CRUD admin panel using Retool connected to a PostgreSQL database. Covers data source connection, table components, detail views, create/update/delete operations, search, role-based access, and security. Built in 6 hours for a 20-person operations team at $200/month versus an estimated 3-4 weeks for custom development.

Overview

Internal tools (admin panels, dashboards, CRUD interfaces) consume a disproportionate amount of engineering time relative to their complexity. Retool is a low-code platform for building internal applications by connecting to databases and APIs, dragging pre-built UI components, and writing queries. This tutorial covers building a CRUD admin panel connected to a PostgreSQL database.

When to Use Retool

Retool is best suited for internal tools that:

  • Need to be built in hours or days, not weeks
  • Require direct database access (read and write)
  • Serve internal teams (operations, support, finance) rather than external customers
  • Need forms, tables, charts, and action buttons

As of April 2026, Retool offers a free tier for up to 5 users with unlimited apps. The Team plan costs $10/user/month. Self-hosted options are available for Enterprise customers.

Prerequisites

  • Retool account (free tier or Team plan)
  • PostgreSQL database accessible from the internet (or Retool self-hosted for private networks)
  • Database credentials with appropriate read/write permissions

Step 1: Connect the PostgreSQL Data Source

  1. In Retool, navigate to Resources > Create New > PostgreSQL
  2. Enter connection details:
    • Host: The database hostname or IP address
    • Port: 5432 (default)
    • Database name: The target database
    • Username: A dedicated Retool service user
    • Password: The service user password
  3. Enable SSL if the database requires encrypted connections
  4. Click "Test Connection" to verify, then "Save"

For production databases, create a read-write user with access limited to the specific tables the internal tool needs. Avoid using superuser credentials.

Step 2: Create a New Application

Click "Create New" > "App" and name it (for example, "Order Management Panel"). Retool opens the application editor with a blank canvas.

The editor has three main areas:

  • Canvas (center) — Drag and arrange UI components
  • Component panel (left) — Library of pre-built components
  • Query editor (bottom) — Write and manage database queries

Step 3: Write the Data Query

Click "+" in the query editor to create a new query. Select the PostgreSQL resource. Write a SELECT query:

SELECT
  id,
  customer_name,
  email,
  order_date,
  status,
  total_amount
FROM orders
ORDER BY order_date DESC
LIMIT 100

Name the query getOrders. Click "Run" to test. The results appear in the query output panel.

Step 4: Add a Table Component

Drag a "Table" component from the component panel onto the canvas. In the table's properties panel:

  • Set Data to {{ getOrders.data }}
  • Configure column visibility (hide internal IDs, format dates, add currency symbols)
  • Enable sorting and filtering
  • Enable row selection (single or multi-select)

The table automatically populates with the query results and updates when the query re-runs.

Step 5: Add a Detail View

Add a "Container" component to the right of the table. Inside it, add:

  • Text Input components for editable fields (customer_name, email, status)
  • Number Input for total_amount
  • Date Picker for order_date
  • Text components for read-only fields (id, created_at)

Bind each component to the selected table row:

  • Customer Name input: Default value = {{ table1.selectedRow.customer_name }}
  • Email input: Default value = {{ table1.selectedRow.email }}
  • Status input: Default value = {{ table1.selectedRow.status }}

When a user clicks a row in the table, the detail view populates with that row's data.

Step 6: Add Update and Delete Queries

Create an update query named updateOrder:

UPDATE orders
SET
  customer_name = {{ customerNameInput.value }},
  email = {{ emailInput.value }},
  status = {{ statusInput.value }},
  total_amount = {{ totalAmountInput.value }}
WHERE id = {{ table1.selectedRow.id }}

Create a delete query named deleteOrder:

DELETE FROM orders WHERE id = {{ table1.selectedRow.id }}

Both queries use Retool's {{ }} template syntax to reference component values.

Step 7: Add Action Buttons

Add "Button" components to the detail view:

  • Save button: On click, run updateOrder query, then run getOrders to refresh the table
  • Delete button: On click, show a confirmation dialog, then run deleteOrder and getOrders

Configure the Save button's event handler:

  1. Click the button component
  2. Add event handler: "Click" > "Run query" > updateOrder
  3. Add a second handler: On success of updateOrder > "Run query" > getOrders
  4. Add a third handler: On success > "Show notification" > "Order updated"

Step 8: Add a Create Form

Add a "Modal" component triggered by a "New Order" button. Inside the modal, add input components for each required field. Create an insert query named createOrder:

INSERT INTO orders (customer_name, email, order_date, status, total_amount)
VALUES (
  {{ newCustomerName.value }},
  {{ newEmail.value }},
  {{ newOrderDate.value }},
  {{ newStatus.value }},
  {{ newTotalAmount.value }}
)

Add a "Submit" button inside the modal that runs createOrder, closes the modal, and refreshes getOrders.

Step 9: Add Search and Filtering

Add a "Text Input" component above the table for search. Modify the getOrders query:

SELECT id, customer_name, email, order_date, status, total_amount
FROM orders
WHERE
  ({{ !searchInput.value }} OR customer_name ILIKE {{ '%' + searchInput.value + '%' }}
   OR email ILIKE {{ '%' + searchInput.value + '%' }})
ORDER BY order_date DESC
LIMIT 100

Set the search input to trigger getOrders on change (with a debounce of 300ms to avoid excessive queries).

Step 10: Deploy and Share

Click "Share" in the top-right corner. Retool apps are accessible via URL within the Retool workspace. Set permissions:

  • Admin: Full access to edit the app and run all queries
  • User: Can use the app but not edit it
  • Viewer: Read-only access

Security Considerations

  • Use parameterized queries (Retool's {{ }} syntax automatically parameterizes values to prevent SQL injection)
  • Create a database user with minimum required permissions
  • Enable Retool audit logs to track who made changes
  • Use Retool environments (staging/production) to prevent accidental changes to production data

Editor's Note: We built an order management panel in Retool for a 20-person operations team at an ecommerce company. Total build time: 6 hours from blank canvas to deployed app with CRUD operations, search, and role-based access. The same tool would have taken an estimated 3-4 weeks to build as a custom React application. Retool cost: $10/user/month for 20 users = $200/month. The main limitation: Retool apps are functional but not visually polished. They serve internal teams well, but the UI is not suitable for customer-facing tools. Additionally, complex business logic (multi-step validation, conditional workflows) requires JavaScript queries within Retool, which reduces the low-code advantage.

Written & reviewed by Rafal Fila · Last updated:

Tools Mentioned

Related Guides

Related Rankings

Best Human-in-the-Loop Automation Platforms 2026

Eight platforms are ranked here on a single mechanism: how a person enters an automated path, and what the system can prove afterward about the decision they made. Moxo scores 7.7 and ranks first; Camunda 8 scores 7.2, Microsoft Power Automate 7.1, Pega 6.9, n8n 6.7, Zapier 5.9, Kissflow 5.8 and ServiceNow 4.8, scored 22 September 2026 on the five weighted criteria. Those criteria cover the step type, the approver's account or licence, the routes available on a rejection, the audit record, and the meter that charges for the decision, and none of them can tell a review from a rubber stamp, so the methodology adds a check readers can run on any product in a few minutes: whether the decision record tells a considered approval from an instant one. Every figure was read from a vendor-owned surface and carries its own date.

Best Automation Platforms for AI Orchestration 2026

This ranking answers one question: how many real business applications can an AI agent act on out of the box? It evaluates nine platforms as of August 2026 on the reach they give an agent, not on the workflow logic they can express. That boundary is deliberate, because two neighbouring pages on this site answer different questions. Best Process Orchestration Platforms 2026 scores multi-step process control, error handling and state management. Best AI Agent Platforms 2026 scores building and hosting the agent itself. This page scores the layer between them: the connective tissue that lets an agent already built elsewhere reach the applications a business actually runs on. A platform that leads one of those pages can place low here, and two of them do. Scores derive from application and action catalogue counts, the exposure model each platform uses to publish those catalogues to an agent, setup effort, failure handling and cost per agent action. Every figure was retrieved from a vendor-owned surface on 11 August 2026 unless an earlier date is stated against it.

Common Questions

How do banks and wealth firms use Moxo for client onboarding?

Moxo's financial-services page (read 13 October 2026) pitches account opening and KYC reviews as shared work: the client gets a secure link to see what is needed and sign, while relationship managers, compliance and operations staff review and approve inside one tracked flow. The named bank case studies do not describe the current product, though: Moxo told Automation Atlas in writing on 6 October 2026 that its Citibank, BNP Paribas and Bank of Queensland stories describe Moxo Classic.

Can healthcare teams run patient-facing workflows on Moxo?

Yes for coordination work, once a signed BAA is in hand: Moxo told Automation Atlas in writing on 6 October 2026 that it signs BAAs, but it publishes none and did not say which plans the agreement covers or whether it reaches Moxo AI. Moxo says it has no native EHR, HL7 or FHIR connector, so anything that reads or writes the chart runs through its REST API or webhooks, or through a tool that signs its own BAA. These are vendor statements.

Who is accountable when an AI agent acts in a Moxo workflow?

The company that deploys the agent is accountable: Moxo's Terms and Conditions (read 13 October 2026) make the customer "solely responsible for any AI Content, including the accuracy, quality, appropriateness, and legality thereof". In the workflow, a named person owns each human step, Moxo's REST API refuses an organisation key for completing it, AI agents are their own user kind, and the record shows who completed a step but nothing documented shows the approver read it (API 2.0.0, read 13 October 2026).

How does Moxo keep humans in control when AI agents run a workflow?

Moxo keeps people on the decisions by design: approvals and other human steps are ones its product page says "only a person can close", and AI agents can fill preparer, advisor or reviewer slots around them (both read 15 September 2026). The checks on AI output are opt-in, though. In synthetic AutomationAtlas tests that day, an AI extract step's "Human review" and "Supervisor Agent" switches were both off by default, and the builder accepted the same role as a form's submitter and its approver.