Skip to content

Main content

SQLite REPL Source Code

Browse the implementation files for SQLite REPL.
tool.ts typescript
import SQLiteRepl from './SQLiteRepl.svelte';
import { formatSQLiteResult } from './result';
import { createSQLiteSession } from './runtime';

export const sqliteRepl = async (
	source: unknown
): Promise<string> => {
	if (typeof source !== 'string' || source.trim() === '')
		return '';

	const session = await createSQLiteSession();
	try {
		return formatSQLiteResult(session.execute(source));
	} finally {
		session.dispose();
	}
};

export const Tool: TypeTool = {
	name: 'SQLite REPL',
	slug: 'repl/sqlite',
	parentSlug: 'repl',
	intro:
		'Run SQLite commands locally in your browser with tabular results and a database that persists for the current session.',
	tool: sqliteRepl,
	i: [],
	o: [
		{
			label: 'SQLite REPL',
			placeholder: 'SQLite REPL',
			render: 'custom',
			renderas: SQLiteRepl,
			type: 'text'
		}
	],
	alternative: [{ title: 'REPL Tools', url: '/repl' }],
	cite: [
		{
			title: 'SQLite Documentation',
			url: 'https://www.sqlite.org/docs.html'
		},
		{
			title: 'sql.js',
			url: 'https://github.com/sql-js/sql.js/'
		}
	]
};

export default Tool;

Description

Browse the implementation files for SQLite REPL.

References

  1. Tool.io on GitHub
  2. Tool.io TypeScript tools library

Similar or alternative tools