Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

895
Vistas
How to connect Google Cloud Bigquery with NodeJS using APIKey

I am trying to insert, delete, search and update in google bigquaey using node js. I have followed up the all documents in google could. But no where its mentioned, how to connect - So I have created this, --

How to connect GCP BigQuery with NodeJS. I am new here. Any help will work.

the code which I have written -

const {BigQuery} = require('@google-cloud/bigquery');

const mainFunction = () => {
    insertIntoBigQuery("John", "john@gmail.com", "+1-23232344231");
}

async function insertIntoBigQuery(name, email, phone) {
// const insertIntoBigQuery = async(name, email, phone) => {
    const bigqueryClient = new BigQuery();
    // The SQL query to run
    const sqlQuery = "INSERT INTO `p4tyu78.Backend_testing.Test1` VALUES ("+name+ "," +email+","+ phone+")";

    const options = {
        query: sqlQuery,
        // Location must match that of the dataset(s) referenced in the query.
        location: 'US',
    };

    // Run the query
    const [rows] = await bigqueryClient.query(options);

    console.log('Rows:');
    rows.forEach(row => console.log(`${row.subject}: ${row.num_duplicates}`));
}

const updateIntoBigQuery = () => {
    
}

const deleteFromBigQuery = () => {
    
}

const searchFromBigQuery = async() => {
    const bigqueryClient = new BigQuery();
    // The SQL query to run
    const sqlQuery = "SELECT * from `p4tyu78.Backend_testing.Test1`";

    const options = {
        query: sqlQuery,
        // Location must match that of the dataset(s) referenced in the query.
        location: 'US',
    };

    // Run the query
    const [rows] = await bigqueryClient.query(options);

    console.log('Rows:');
    rows.forEach(row => console.log(`${row.subject}: ${row.num_duplicates}`));
}

mainFunction();
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Forget the API key, you can't use it for BigQuery (and it's still working with legacy API, but very few). You need to use OAuth2 mechanism to be authenticated.

When you use a Google Cloud API, you need to add an access token in the header of your API request. But in your case, you don't perform directly these API call, you use the client library.

You have a description of the authentication in the documentation. To go quicker, on Google Cloud environment, you can rely on the service service account. In some service you can customize them. You can alse use you own credential, on your computer, and a service account key file on external platform (on prem, on other cloud provider).

So, in your case, you initiate the bigquery library like this const bigqueryClient = new BigQuery();. That means you rely on the environment credential to be connected to BigQuery.

On your environment, to use your own credential, you can use gcloud CLI and run this

gcloud auth application-default login

Login and enjoy!!

But the security is a long way on GCP, it's only the beginning, ask again later if you have difficulties in your choices

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda