Last active
April 29, 2019 14:31
-
-
Save ceoro9/64823e39b45eeeaf2001c9b3b95a8d65 to your computer and use it in GitHub Desktop.
Insert data to BigQuery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func insertRows(client *bigquery.Client, datasetID, tableID string) error { | |
ctx := context.Background() | |
// [START bigquery_table_insert_rows] | |
u := client.Dataset(datasetID).Table(tableID).Uploader() | |
items := []*Item{ | |
// Item implements the ValueSaver interface. | |
{Name: "Phred Phlyntstone", Age: 32}, | |
{Name: "Wylma Phlyntstone", Age: 29}, | |
} | |
if err := u.Put(ctx, items); err != nil { | |
return err | |
} | |
// [END bigquery_table_insert_rows] | |
return nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment