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();
}We're live here https://discord.com/channels/930051556043276338/1278977038430240813
henri-c · 6d ago
Infrastructure as code
rubenf · 4w ago
As we're preparing for a new Windmill sandbox SDK, we took the opportunity **to open-source NSJAIL sandboxing** and make it available in CE and easier to set. In 1.634.0, just set nsjail to benefit from the tightest security and isolation per job. It's constraining so no need to use it unless you need but now you won't be restricted in security for CE if you need to.
rubenf · 4w ago