diff options
Diffstat (limited to 'tables/src')
| -rw-r--r-- | tables/src/main.rs | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/tables/src/main.rs b/tables/src/main.rs index 4f552a6..9756906 100644 --- a/tables/src/main.rs +++ b/tables/src/main.rs @@ -8,19 +8,21 @@ async fn main() -> anyhow::Result<()> { .context("You should provide path to the database")? .parse::<String>()?; + let vert_num = std::env::args() + .nth(2) + .context("You should provide size of graphs")? + .parse::<usize>()?; + if !sqlx::Sqlite::database_exists(&database_url).await? { return Err(anyhow::Error::msg(format!( "Database {database_url} not found" ))); } let db = sqlx::SqlitePool::connect(&database_url).await?; - let g0 = sqlx::query("SELECT size FROM graphs LIMIT 1") - .fetch_one(&db) - .await?; - let vert_num = g0.get::<i32, &str>("size") as usize; println!("Size of graphs: {vert_num}"); let mut res = vec![vec![0; vert_num + 1]; vert_num + 1]; - let graphs = sqlx::query("SELECT ind_dom, forced_geod FROM graphs") + let graphs = sqlx::query("SELECT ind_dom, forced_geod FROM graphs WHERE size=?") + .bind(vert_num as u32) .fetch_all(&db) .await?; let mut cnt = 0; @@ -52,7 +54,7 @@ async fn main() -> anyhow::Result<()> { table.push(format!("& {i} ")); } table.push("\\\\ \\hline\n".to_string()); - for i in 0..=vert_num { + for i in 1..=vert_num { table.push(" ".to_string()); table.push(format!("{i} ")); for j in 0..=vert_num { @@ -61,6 +63,7 @@ async fn main() -> anyhow::Result<()> { table.push(" \\\\ \\hline\n".to_string()); } table.push(" \\end{tabular}\n".to_string()); + table.push(format!(" \\label{{tbl:gr{vert_num}}}\n")); table.push("\\end{table}\n".to_string()); println!("{}", table.join("")); |