Execute SQL Queries Against Databases
Executes SQL queries against DuckDB or SQLite with a configurable read-only mode and timeout, extensible to other SQL databases.
Maintainer of this project? Claim this page to edit the listing.
0.2.90Add to Favorites
Why it matters
Seamlessly execute SQL queries against various SQL databases, supporting both read-only and read-write operations. This toolkit simplifies data interaction for applications and developers.
Outcomes
What it gets done
Connect to DuckDB and SQLite databases.
Execute SELECT, INSERT, UPDATE, and DELETE queries.
Configure read-only or read-write access modes.
Manage database connections with optional timeouts.
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/camel-sqltoolkit | bash Overview
SQLToolkit
A toolkit for executing SQL queries against DuckDB or SQLite databases, in-memory or file-backed, with a configurable read-only mode that blocks write operations and a configurable operation timeout. Use it when an agent needs to query a DuckDB or SQLite database, especially when a read-only safeguard against accidental writes is needed.
What it does
This toolkit executes SQL queries against SQL databases, with support for both read-only and read-write modes. It currently supports DuckDB and SQLite, with extensibility noted for MySQL and other SQL databases. Configuration includes an optional database_path (defaults to an in-memory database if not set; for DuckDB and SQLite, use :memory: for in-memory or a file path for persistent storage), a database_type literal currently accepting "duckdb" or "sqlite" (default "duckdb"), a read_only flag that, when True, restricts execution to SELECT queries and rejects write operations (INSERT, UPDATE, DELETE, etc.), and a timeout for database operations in seconds, defaulting to 180.0 if unspecified. It raises a ValueError if database_type is unsupported, and an ImportError if the required database driver isn't installed.
When to use - and when NOT to
Use it when an agent needs to run SQL queries against a DuckDB or SQLite database, whether in-memory or file-backed, and needs an enforced read-only mode to prevent accidental writes.
Do not use it for database types beyond DuckDB and SQLite without confirming driver support first - unsupported types raise a ValueError, and a missing driver raises an ImportError.
Inputs and outputs
Input is SQL queries plus the toolkit's configuration: database_path, database_type (duckdb or sqlite), read_only, and timeout. Output is the query execution result; in read_only mode, only SELECT queries execute and any write operation is rejected outright.
Integrations
Supports DuckDB and SQLite natively, with the codebase noting extensibility toward MySQL and other SQL databases.
Who it's for
Developers building agents that need to query or, when explicitly allowed, modify a DuckDB or SQLite database, with a built-in safeguard to enforce read-only access when needed.
Source code
A toolkit for executing SQL queries against various SQL databases.
This toolkit provides functionality to execute SQL queries with support
for read-only and read-write modes. It currently supports DuckDB and
SQLite, with extensibility for MySQL and other SQL databases.
Args:
database_path (Optional[str]): Path to the database file. If None,
uses an in-memory database. For DuckDB and SQLite, use ":memory:"
for in-memory or a file path for persistent storage.
(default: :obj:None)
database_type (Literal["duckdb", "sqlite"]): Type of database to use.
Currently supports "duckdb" and "sqlite".
(default: :obj:"duckdb")
read_only (bool, optional): If True, only SELECT queries are allowed.
Write operations (INSERT, UPDATE, DELETE, etc.) will be rejected.
(default: :obj:False)
timeout (Optional[float], optional): The timeout for database
operations in seconds. Defaults to 180 seconds if not specified.
(default: :obj:180.0)
Raises:
ValueError: If database_type is not supported.
ImportError: If required database driver is not installed.
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.