with TimescaleDB and Schedule?
import { Pool } from 'pg'; //required by sequelize
import { Sequelize } from "sequelize";
export default defineComponent({
props: {
timescaledb: {
type: "app",
app: "timescaledb",
}
},
async run({steps, $}) {
//Creating object with connection to TimescaleDB instance
const sequelize = new Sequelize({
dialect: 'postgres',
protocol: 'postgres',
host: this.timescaledb.$auth.host,
port: this.timescaledb.$auth.port,
username: this.timescaledb.$auth.user,
password: this.timescaledb.$auth.password,
database: this.timescaledb.$auth.database,
dialectOptions: {
ssl: {
require: true,
rejectUnauthorized: this.timescaledb.$auth.ssl_verification_mode === 'verify_identity'
}
}
})
// Test the connection and return the result
try {
await sequelize.authenticate()
const queryInterface = sequelize.getQueryInterface();
const [results, metadata] = await queryInterface.sequelize.query('SELECT 1+1 AS result');
return results;
} catch (error) {
throw new Error(`Unable to connect to the database: ${error}`)
} finally {
await sequelize.close()
}
},
})
The Schedule app in Pipedream is a powerful tool that allows you to trigger workflows at regular intervals, ranging from every minute to once a year. This enables the automation of repetitive tasks and the scheduling of actions to occur without manual intervention. By leveraging this API, you can execute code, run integrations, and process data on a reliable schedule, all within Pipedream's serverless environment.