POST /api/connect
endpointPOST /api/connect
Body: { connectionString: string }
Returns: { sessionId, schema, canWrite, suggestedQuestions }Opens a connection to a live database (SQLite, PostgreSQL, or MySQL-ready), pings it, introspects the schema, and creates a session. Returns the schema snapshot, write-privilege flag, and suggested starter questions based on the real tables. Per-table COUNT queries have a 3-second statement_timeout so a single slow table doesn't block introspection.
Parameters
- connectionString · string
- A SQLite file path, 'demo' for the bundled DB, or a postgresql:// / mysql:// URL.
Returns
Session object with schema, canWrite flag, and suggested questions.
Example
const res = await fetch("/api/connect", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ connectionString: "demo" }),
});
const { sessionId, schema, suggestedQuestions } = await res.json();