Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stack overflow exception then trying to get sqlite schema on an empty turso database on Windows (only) #1349

Open
milen-denev opened this issue Apr 26, 2024 · 1 comment

Comments

@milen-denev
Copy link

Stack overflow exception then trying to get sqlite schema on an empty turso database on Windows (only). Works on linux (Fedora v40), unknown for MacOs.

use libsql::{Builder, Connection};


#[tokio::main]
async fn main() {
    let builder = Builder::new_remote("libsql://<subdomain>.turso.io".into(), "<token>".into()).build().await.unwrap();
    let connection = builder.connect().unwrap();
    get_current_db_schema("Test", &connection).await;
}

pub async fn get_current_db_schema(name: &str, connection: &Connection) -> Option<Vec<String>> {  
    let query = format!("SELECT sql FROM sqlite_schema WHERE name = {}", name);

    let result_query = connection
         .query(&query, ())
         .await;

    if let Ok(mut result_row) = result_query {
         let result_rows = result_row
              .next()
              .await;

         if let Ok(_result_row) = result_rows {
              return None;
         }
         else {
              return None;
         }

    }
    else {
         return None;
    }
}

Repository with the same code: https://github.com/milen-denev/libsql_stackoverflow/

@milen-denev
Copy link
Author

#1051

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant