-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathinsert.ts
More file actions
32 lines (27 loc) · 783 Bytes
/
insert.ts
File metadata and controls
32 lines (27 loc) · 783 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { Client } from "https://deno.land/x/postgres/mod.ts";
const client = new Client({
user: "MATERIALIZE_USERNAME",
database: "materialize",
password: "APP_SPECIFIC_PASSWORD",
hostname: "MATERIALIZE_HOST",
port: 6875,
ssl: true,
})
const main = async ({ response }: { response: any }) => {
try {
await client.connect()
await client.queryObject(
"INSERT INTO countries(code, name) VALUES($1, $2)",
['GH', 'GHANA'],
);
const result = await client.queryObject("SELECT * FROM countries")
console.log(result.rows)
} catch (err) {
console.error(err.toString())
} finally {
await client.end()
}
}
export { main }
// Call the main function
main({ response: {} })