Skip to main content

ConnectionAskExt

Trait ConnectionAskExt 

Source
pub trait ConnectionAskExt {
    // Required method
    fn ask(
        &self,
        question: &str,
        config: &AskConfig,
    ) -> Result<AskResponse, AskError>;
}
Expand description

Extension trait adding Connection::ask to crate::Connection. Bring it into scope with use sqlrite::ConnectionAskExt; (the engine re-exports it at the crate root).

Gated under the ask feature — pulls in sqlrite-ask and its HTTP transport. WASM and other lean builds skip this entirely.

Required Methods§

Source

fn ask( &self, question: &str, config: &AskConfig, ) -> Result<AskResponse, AskError>

Generate SQL from a natural-language question.

Internally: dump the schema, build the cache-friendly prompt, POST to the configured LLM provider, parse the JSON-shaped reply.

use sqlrite::{Connection, ConnectionAskExt};
use sqlrite_ask::AskConfig;

let conn = Connection::open("foo.sqlrite")?;
let cfg  = AskConfig::from_env()?;          // SQLRITE_LLM_API_KEY etc.
let resp = conn.ask("how many users are over 30?", &cfg)?;
println!("{}", resp.sql);

Implementors§

Source§

impl ConnectionAskExt for Connection

Available on crate feature ask only.