fej/src/populate_ivago.rs

20 lines
646 B
Rust
Raw Normal View History

2021-04-17 23:20:41 +02:00
use diesel::{insert_into, Connection, PgConnection, RunQueryDsl};
use fej::ivago::search_streets;
use fej::schema::ivago_streets::dsl::*;
const ABC: &str = "abcdefghijklmnopqrstuvwxyz";
fn main() {
let database_url = std::env::var("DATABASE_URL").expect("DATABASE_URL must be set");
let db_conn = PgConnection::establish(&database_url)
.expect(&format!("Error connecting to {}", database_url));
// Doing this linearly is good enough I'd say
for c in ABC.chars() {
if let Ok(streets) = search_streets(&c.to_string()) {
insert_into(ivago_streets).values(streets).execute(&db_conn);
}
}
}