serde_sheets

Crates.ioserde_sheets
lib.rsserde_sheets
version0.1.2
sourcesrc
created_at2022-05-02 10:42:55.687684
updated_at2022-05-02 10:42:55.687684
descriptionRead and write structs directly from google sheets using serde and csv
homepage
repository
max_upload_size
id579006
size37,971
(georgewhewell)

documentation

README

serde_sheets

Read and write structs directly from google sheets using serde and csv

Implement serde::Serialize to write and serde::Deserialize to read. Easy!

Motivation

Google sheets API is somewhat complex and requires lots of boilerplate. Reading and writing involves using lots of Vec<Vec<String>>. We use csv crate to automate creating these payloads and converting them back into your structs

Usage

serde_sheets expects a google service account json to be available as SERVICE_ACCOUNT_JSON:

$ export SERVICE_ACCOUNT_JSON=$(cat my-service-account.json)

Build Sheets object:

let service_account = service_account_from_env().unwrap();
let mut sheets = get_sheets(service_account, Some("token_cache.json"))
    .await
    .unwrap();

Write objects:

serde_sheets::write_page(&mut sheets, "some-document-id", "some-tab-name", &objects)
    .await
    .unwrap();

Read objects:

let returned: Vec<ExampleObject> = serde_sheets::read_all(&mut sheets, DOCUMENT_ID, TAB_NAME)
    .await
    .unwrap();

Check examples/example.rs for full example.

$ cargo run --example example

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Commit count: 0

cargo fmt