executeSQL
Signature
function executeSQL<T = unknown>(databasePath: string, query: string): Promise<T[]>Arguments
Return
Example
import { closeMainWindow, Clipboard } from "@raycast/api";
import { executeSQL } from "@raycast/utils";
type Message = { body: string; code: string };
const DB_PATH = "/path/to/chat.db";
export default async function Command() {
const query = `
SELECT body, code
FROM message
ORDER BY date DESC
LIMIT 1;
`;
const messages = await executeSQL<Message>(DB_PATH, query);
if (messages.length > 0) {
const latestCode = messages[0].code;
await Clipboard.paste(latestCode);
await closeMainWindow();
}
}Last updated

