import { BigQuery } from "@google-cloud/bigquery";
type Gcloud = {
type: string;
project_id: string;
private_key_id: string;
private_key: string;
client_email: string;
client_id: string;
auth_uri: string;
token_uri: string;
auth_provider_x509_cert_url: string;
client_x509_cert_url: string;
universe_domain: string;
};
export async function main(
resource: Gcloud,
datasetId: string,
tableId: string,
rows: object[]
) {
const bigQueryClient = new BigQuery({
credentials: resource,
projectId: resource.project_id,
});
const response = await bigQueryClient
.dataset(datasetId)
.table(tableId)
.insert(rows);
return response;
}
Submitted by hugo697 692 days ago
import { BigQuery } from "@google-cloud/bigquery";
type Gcloud = {
type: string;
project_id: string;
private_key_id: string;
private_key: string;
client_email: string;
client_id: string;
auth_uri: string;
token_uri: string;
auth_provider_x509_cert_url: string;
client_x509_cert_url: string;
universe_domain: string;
};
export async function main(
resource: Gcloud,
datasetId: string,
tableId: string,
rows: object[]
) {
const bigQueryClient = new BigQuery({
credentials: resource,
projectId: resource.project_id,
});
const response = await bigQueryClient
.dataset(datasetId)
.table(tableId)
.insert(rows);
return response;
}
Submitted by hugo697 693 days ago
import { BigQuery } from "@google-cloud/bigquery";
type Gcloud = {
projectId: string;
privateKey: string;
clientEmail: string;
};
export async function main(
resource: Gcloud,
datasetId: string,
tableId: string,
rows: object[]
) {
const credentials = {
client_email: resource.clientEmail,
private_key: resource.privateKey.replace(/\\n/g, "\n"),
};
const bigQueryClient = new BigQuery({
credentials,
projectId: resource.projectId,
});
const response = await bigQueryClient
.dataset(datasetId)
.table(tableId)
.insert(rows);
return response;
}
Submitted by hugo697 693 days ago