Skip to content

SQLDatabase

Connects to a SQL database to run queries and retrieve data

How it Works

The SQLDatabase component builds a connection string (URI) using the information you provide—username, password, hostname, port, and database name. It then creates a SQLDatabase object that can be used by other components to run SQL queries. The component also gives you the full URI as a text message so you can see or log the connection details.

Inputs

  • Database: The name of the database you want to connect to.
  • Hostname: The address of the server where the database is hosted.
  • Password: The password for the database user.
  • Port: The port number the database listens on (defaults to 5432 if left blank).
  • Table to use: If you know the specific table you’ll be working with, enter its name here.
  • User: The username that has access to the database.

Outputs

  • SQLDatabase: A SQLDatabase object that can be passed to other components to execute queries.
  • URI Database string: A text message containing the full connection URI, useful for logging or debugging.

Usage Example

  1. Drag the SQLDatabase component onto the canvas.
  2. Fill in the required fields:
    • User: db_user
    • Password: securePass123
    • Hostname: db.example.com
    • Database: sales
    • Port: (leave blank to use the default 5432)
    • Table to use: orders (optional)
  3. Connect the SQLDatabase output to a SQLQuery component.
  4. In the SQLQuery component, write a query such as SELECT * FROM orders LIMIT 10;.
  5. Run the workflow. The query will execute against the database you connected to, and the results will appear in the next component.
  • SQLQuery – Uses the SQLDatabase output to run custom SQL statements and return query results.
  • DatabaseConnector – A higher‑level component that can manage multiple database connections and switch between them.

Tips and Best Practices

  • Keep your database credentials out of version control; use environment variables or a secrets manager.
  • Test the connection with a simple query before building complex workflows.
  • If you only need to read data, consider using the Table to use field to limit the scope of the connection.
  • Use the URI Database string output to verify that the connection string is correct, especially when troubleshooting.

Security Considerations

  • Never expose the password field in public dashboards or logs.
  • Store credentials in encrypted form and restrict access to the component’s settings.
  • Use secure network connections (SSL/TLS) when connecting to remote databases.
  • Regularly rotate database passwords and update the component’s inputs accordingly.