td-client-rust
Rust Client Library for Treasure Data
Install
Add the following dependency in Cargo.toml
[dependencies]
td-client = "0.2"
Usage
First, add this line to your crate root
extern crate td_client;
Next, set up a td-client with your API key for Treasure Data
use *;
use *;
let client = new;
Manipulate Database metadata
client.create_database.unwrap;
println!;
client.delete_database.unwrap;
Manipulate Table metadata
client.create_table.unwrap;
println!;
client.swap_table.unwrap;
client.rename_table.unwrap;
client.delete_table.unwrap;
Import data to table
// Import msgpack gzipped file
client.import_msgpack_gz_file_to_table.unwrap;
// Import records
let mut chunk = new.unwrap;
chunk.next_row.unwrap;
chunk.write_key_and_i64.unwrap;
chunk.write_key_and_str.unwrap;
chunk.write_key_and_u8.unwrap;
chunk.write_key_and_f32.unwrap;
chunk.next_row.unwrap;
chunk.write_key_and_i64.unwrap;
chunk.write_key_and_str.unwrap;
chunk.write_key_and_u8.unwrap;
let readable_chunk = chunk.close.unwrap;
client.import_msgpack_gz_file_to_table.unwrap;
Information of jobs
// List up jobs
println!;
// Look at the job
println!;
// Check the job's status
println!;
Issue a query
// Issue a query
let job_id = client.issue_job.unwrap;
println!;
// Download the result to a file
let result_file = create.unwrap;
client.download_job_result.unwrap;
// Do something for each record
client.each_row_in_job_result;