vertica / vertica-nodejs

Official native node.js client for the Vertica Analytics Database.
https://www.vertica.com/
Apache License 2.0
12 stars 14 forks source link

Cannot insert data #102

Closed negreanucalin closed 1 year ago

negreanucalin commented 1 year ago

I am indeed new to Vertica but I tried several options to insert data.

One of my latest attempts (from examples):

import * as dotenv from 'dotenv';

dotenv.config();

const {Client} = require('vertica-nodejs')

const verticaInsert = () => {
    const client = new Client()
    client.connect()
    client.query("INSERT INTO public.testing (call_id) VALUES (2)", (err: any, res: any) => {
        console.log(err)
        console.log(res.rows)
        client.query("SELECT * FROM public.testing", (err: any, res: any) => {
            console.log(err || res.rows[0])
            client.end()
        })
    })
}
verticaInsert();

Output seems okay:

root@d9de246fd6ff:/usr/src/app# ./node_modules/.bin/ts-node src/test_vertics.ts 
null
[ { OUTPUT: 1 } ]
{ call_id: '100' } // Initial data

Configuration: Node: v14.20.1 Vertica Analytic Database: v12.0.0-0

I can select the data as seen above but the data is inserted, is there something I am missing?

Inxo commented 1 year ago

i think you forgot about “COMMIT;”