The SQL query to run.
async
(params, auths) => {
}
const axios = require('axios')
const response = await axios({
url: `https://rt.pipedream.com/sql`,
method: 'POST',
headers: {
Authorization: `Bearer ${auths.pipedream.api_key}`,
},
data: {"query": params.query}
})
if (response.data.error.toDisplay) {
throw(response.data.error.toDisplay)
} else {
const rv = {}
const metadata = {}
rv.columnInfo = response.data.resultSet.ResultSetMetadata.ColumnInfo
rv.queryExecutionId = response.data.queryExecutionId
rv.csvLocation = `https://rt.pipedream.com/sql/csv/${response.data.resultsFilename}`
let resultSet = []
if (params.returnFormat === "object") {
let headers = response.data.resultSet.Rows.shift()
for (let j = 0; j < response.data.resultSet.Rows.length; j++) {
let row = response.data.resultSet.Rows[j]
let obj = {}
for (let i = 0; i < row.Data.length; i++) {
obj[headers.Data[i].VarCharValue] = row.Data[i].VarCharValue
}
resultSet.push(obj)
}
} else {
response.data.resultSet.Rows.forEach(row => {
let map = row.Data.map(data => data.VarCharValue)
resultSet.push(map)
})
}
rv.results = resultSet
//rv.metadata = metadata
return rv
}
An array of arrays representing the rows, for example [[1, 2, 3], [4, 5, 6]]
The ID of the target spreadsheet, found at the end of the URL: https://docs.google.com/spreadsheets/d/{id}
The sheet you'd like to add a row to
async
(params, auths) => {
}
const data = {
values: params.rows,
}
const config = {
method: "post",
url: `https://sheets.googleapis.com/v4/spreadsheets/${params.spreadsheetId}/values/${params.sheetName}:append`,
params: {
includeValuesInResponse: true,
valueInputOption: "USER_ENTERED"
},
headers: {
Authorization: `Bearer ${auths.google_sheets.oauth_access_token}`,
},
data,
}
return await require("@pipedreamhq/platform").axios(this, config)