import * as wmill from "windmill-client"
import { Client } from "pg"
import { from as copyFrom } from "pg-copy-streams"
// Defining the type for Postgres resource
type Postgresql = {
host: string,
port: number,
user: string,
dbname: string,
sslmode: string,
password: string,
root_certificate_pem: string
}
export async function main(csvFile: string, postgresqlResource: Postgresql) {
//Start up db connection
//Creating a new postgres client
const client = new Client({
user: postgresqlResource.user,
database: postgresqlResource.dbname,
password: postgresqlResource.password,
host: postgresqlResource.host, // Changed from hostname to host
port: postgresqlResource.port
});
let stream;
const time = new Date().toISOString();
try {
await client.connect();
//test to make sure connection is working.
//await client.query("INSERT INTO inventory (sku,warehouse_id,time,qty) VALUES ('test',2,now(),25)");
stream = await client.query(copyFrom('COPY inventory (sku,warehouse_id,time,qty) FROM STDIN'));
let numOfRows = 0;
stream.write('partnumber' + '\t' + '2' + '\t' + time + '\t' + '43' + '\n');
//await stream.end();
}
catch (e)
{
console.log(e);
}
finally
{
stream.end();
}@everyone Windmill is the fastest workflow engine but many times the comparison with other workflow engines was stuck on low-code vs full code flows. I'm proud to release the ALPHA of: **Workflow-as-Code v2 — Write workflows as plain code** We completely rebuilt Workflow-as-Code from the ground up. Instead of a visual flow builder, you write your entire workflow as a regular TypeScript or Python script — with all the reliability of Windmill's execution engine behind it. ``` import { task, step, sleep, waitForApproval, workflow } from "windmill-client"; const process = task(async (x: string) => `processed: ${x}`); export const main = workflow(async (x: string) => { const a = await process(x); const urls = await step("get_urls", () => getResumeUrls()); await sleep(60); await waitForApproval({ timeout: 3600 }); return { processed: a }; }); ``` Each task() call runs as a separate checkpointed job — if your workflow fails halfway through, completed steps are skipped on retry. step() checkpoints inline code without spawning a child job. sleep() and waitForApproval() suspend server-side without holding a worker. What's new: - Direct function calls — no more string-based step references or passing context objects. Just wrap your functions with task() and call them normally - Module support — split your workflow across multiple files with taskScript("./helper.ts"), each module gets its own editor tab - Parallel execution — Promise.all() / asyncio.gather() just works - Full primitive set — task, taskScript, step, sleep, waitForApproval, getResumeUrls - Python & TypeScript — both languages supported with idiomatic APIs (@task() decorator in Python) - Live timeline — real-time visualization of step execution, durations, and status in the UI Available now in v1.652+. https://www.windmill.dev/docs/core_concepts/workflows_as_code
rubenf · 5d ago
We're live here https://discord.com/channels/930051556043276338/1278977038430240813
henri-c · 3w ago
Infrastructure as code
rubenf · 2mo ago