2023年1月22日日曜日

Rust language :: rayon,tokio-scraping,rusqlite

https://blog.ymgyt.io/entry/rust_atomics_and_locks/ 並行処理の読後:参考になる


ーーーーーーーーーーーーーーーーーーーーーーーーーーーー

https://crates.io/crates/rayon  ::  summary of rayon 

 https://qiita.com/fujitayy/items/1cb4169406457e2f4867 :: rayon example

[package]name = "rayon-test"

version = "0.1.0"

edition = "2021"


# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html


[dependencies]

rand = "0.6"

rayon = "1.5"


----- tokio scraping --

 https://zenn.dev/su_do/articles/b2ed44a4d5c024

-- rusqlite------------------------------------------------


//--------------------------------------------------------------
/* src/main.rs Jul/23/2020 */ // -------------------------------------------------------------------- use rusqlite::{params, Connection, Result}; #[derive(Debug)] struct City { id: String, name: String, population: i32, } fn main() -> Result<()> { eprintln! ("*** start ***"); let conn = Connection::open_in_memory()?; conn.execute( "CREATE TABLE person ( id VARCHAR(10) PRIMARY KEY, name TEXT NOT NULL, population INTEGER )", params![], )?; conn.execute( "INSERT INTO person (id,name, population) VALUES (?1, ?2, $3)", params!["t0711".to_string(),"郡山".to_string(), 18954], )?; conn.execute( "INSERT INTO person (id, name, population) VALUES (?1, ?2, $3)", params!["t0712".to_string(),"会津若松".to_string(), 83576], )?; conn.execute( "INSERT INTO person (id, name, population) VALUES (?1, ?2, $3)", params!["t0713".to_string(),"白河".to_string(), 51769], )?; let mut stmt = conn.prepare("SELECT id, name, population FROM person")?; let city_iter = stmt.query_map(params![], |row| { Ok(City { id: row.get(0)?, name: row.get(1)?, population: row.get(2)?, }) })?; for city in city_iter { println!("{:?}", city.unwrap()); } eprintln! ("*** end ***"); Ok(()) } // --------------------------------------------------------------------
rusqlite = { version = "0.16", features = ["bundled"] }を
0.24.0としてみた 以下を参考に
Rust で SQLite を動かしてみる (サンプルコードを関数に切り出す) - ブログ (hatenablog.com)

0 件のコメント:

コメントを投稿