Skip to content

Commit

Permalink
Merge pull request #22 from Alex-Monahan/append-on-write
Browse files Browse the repository at this point in the history
Convert to append so >2048 rows can be written.
  • Loading branch information
archiewood authored Oct 24, 2024
2 parents 90f6372 + 403610a commit 9a8c3b4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/gsheets_copy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,11 @@ namespace duckdb
std::string request_body = sheet_data.dump();

// Make the API call to write data to the Google Sheet
std::string response = fetch_sheet_data(gstate.sheet_id, gstate.token, gstate.sheet_name, HttpMethod::PUT, request_body);
// Today, this is only append.
// To overwrite, need to detect if we are the first data chunk and clear out the sheet.
// Is there a way to force that to happen only once, even in the presence of multithreading?
// Maybe this? https://github.com/duckdb/duckdb/pull/7368
std::string response = fetch_sheet_data(gstate.sheet_id, gstate.token, gstate.sheet_name, HttpMethod::POST, request_body);

// Check for errors in the response
json response_json = parseJson(response);
Expand Down
3 changes: 2 additions & 1 deletion src/gsheets_requests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ namespace duckdb
std::string host = "sheets.googleapis.com";
std::string path = "/v4/spreadsheets/" + sheet_id + "/values/" + sheet_name;

if (method == HttpMethod::PUT) {
if (method == HttpMethod::POST) {
path += ":append";
path += "?valueInputOption=RAW";
}

Expand Down

0 comments on commit 9a8c3b4

Please sign in to comment.