Skip to content

Instantly share code, notes, and snippets.

@ceoro9
Last active April 29, 2019 14:31
Show Gist options
  • Save ceoro9/64823e39b45eeeaf2001c9b3b95a8d65 to your computer and use it in GitHub Desktop.
Save ceoro9/64823e39b45eeeaf2001c9b3b95a8d65 to your computer and use it in GitHub Desktop.
Insert data to BigQuery
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