Skip to content

DB Query

Type: db-query  ·  Package: Database Activities v1.0.0  ·  Output: DataTable

Runs a SELECT query and returns the results as a DataTable, ready to traverse, filter, or dump to Excel. It is the most common reading activity.

Runs SELECT over the connection and returns its rows in a DataTable, with one column for each column of the result. Uses parameters @nombre and field params for variable values ​​(see parameterized queries).

ParameterEditorDescription
sqlexpressionThe SELECT statement. Use @nombre for parameters.
ParameterEditorDescription
sessionsessionDB Connect session. Within a body it is inherited automatically; outside, pass = db.
paramsJSONParameter values, as object { nombre: valor }.

Returns a DataTable. Loop through it with For Each and access cells with str(row["Columna"]).

DB Query
sql = "SELECT Id, Nombre, Saldo FROM Clientes WHERE Ciudad = @ciudad"
params = { "ciudad": = ciudadBuscada }
→ output: clientes
Log message = = "Clientes encontrados: " + rowCount(clientes)
For Each items = = clientes itemVariable = fila
└─ activities:
Log message = = str(row["Nombre"]) + ": " + num(fila["Saldo"])
  • DB Scalar — when the SELECT returns a single value.
  • DB Execute — for INSERT/UPDATE/DELETE.
  • DataTable — filter, sort and summarize the result.