Skip to main content

Module ask

Module ask 

Source
Expand description

Engine-side glue for the sqlrite-ask crate — natural-language → SQL.

Compiled only when the ask feature is enabled (default-on for the CLI binary, off for the WASM SDK and any default-features = false library embedding).

§Why this lives in the engine, not in sqlrite-ask

Earlier (v0.1.18) sqlrite-ask itself owned the Connection integration — it imported sqlrite-engine and exposed ConnectionAskExt. That worked for library callers, but when the engine’s REPL binary tried to depend on sqlrite-ask to wire up the .ask meta-command we hit a hard cargo error:

cyclic package dependency: package `sqlrite-ask` depends on itself.
Cycle: sqlrite-ask → sqlrite-engine → sqlrite-ask

Optional / feature-gated deps don’t escape this — cargo’s static cycle detection counts every potential edge in the graph. The structural fix was to flip the dep direction: keep sqlrite-ask pure (operates on &str schemas), put the engine integration here. The dep flow is now one-way: sqlrite-engine[ask]sqlrite-ask. No cycle.

§What’s here

Modules§

schema
Schema introspection — turn an open Connection (or raw Database) into the textual schema dump the LLM uses to ground its SQL generation.

Traits§

ConnectionAskExt
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).

Functions§

ask
Free-function form of ConnectionAskExt::ask. Equivalent — pick whichever shape reads better at the call site.
ask_with_database
Same as ask, but takes the engine’s &Database directly.
ask_with_database_and_provider
Lower-level entry taking &Database and a provider. Canonical inner function — the others reduce to this one.
ask_with_provider
Lower-level entry — same flow as ask but you supply the provider. For test harnesses + advanced callers driving custom backends.