LogoLogo
TwitterWebsite
  • Getting Started
    • Introduction
    • Human UI
    • Examples
    • Monitoring
    • Workflows
    • Getting Help
  • Documentation
    • Humans
      • Introduction
      • Prompts
      • Tools
      • Knowledge
      • Memory
      • Storage
      • Structured Output
      • Reasoning
      • Teams
    • Models
      • Introduction
      • Open AI
      • Open AI Like
      • Anthropic Claude
      • AWS Bedrock Claude
      • Azure
      • Cohere
      • DeepSeek
      • Fireworks
      • Gemini
      • Gemini - VertexAI
      • Groq
      • HuggingFace
      • Mistral
      • Nvidia
      • Ollama
      • OpenRouter
      • Sambanova
      • Together
      • xAI
    • Tools
      • Introduction
      • Functions
      • Writing your own Toolkit
      • Airflow
      • Apify
      • Arxiv
      • AWS Lambda
      • BaiduSearch
      • Calculator
      • Cal.com
      • Composio
      • Crawl4AI
      • CSV
      • Dalle
      • DuckDb
      • DuckDuckGo
      • Email
      • Exa
      • Fal
      • File
      • Firecrawl
      • Giphy
      • Github
      • Google Calendar
      • Google Search
      • Hacker News
      • Jina Reader
      • Jira
      • Linear
      • Lumalabs
      • MLX Transcribe
      • ModelsLabs
      • Newspaper
      • Newspaper4k
      • OpenBB
      • Bitca
      • Postgres
      • Pubmed
      • Pyton
      • Replicate
      • Resend
      • Searxng
      • Serpapi
      • Shell
      • Slack
      • Sleep
      • Spider
      • SQL
      • Tavily
      • Twitter
      • Website
      • Yfinance
      • Zendesk
    • Knowledges
      • Introduction
      • ArXiv Knowledge Base
      • Combined KnowledgeBase
      • CSV Knowledge Base
      • CSV URL Knowledge Base
      • Docx Knowledge Base
      • Document Knowledge Base
      • JSON Knowledge Base
      • LangChain Knowledge Base
      • LlamaIndex Knowledge Base
      • PDF Knowledge Base
      • PDF URL Knowledge Base
      • S3 PDF Knowledge Base
      • S3 Text Knowledge Base
      • Text Knowledge Base
      • Website Knowledge Base
    • Chunking
      • Fixed Size Chunking
      • Agentic Chunking
      • Semantic Chunking
      • Recursive Chunking
      • Document Chunking
    • VectorDBS
      • Introduction
      • PgVector Agent Knowledge
      • Qdrant Agent Knowledge
      • Pinecone Agent Knowledge
      • LanceDB Agent Knowledge
      • ChromaDB Agent Knowledge
      • SingleStore Agent Knowledge
    • Storage
      • Introduction
      • Postgres Agent Storage
      • Sqlite Agent Storage
      • Singlestore Agent Storage
      • DynamoDB Agent Storage
      • JSON Agent Storage
      • YAML Agent Storage
    • Embeddings
      • Introduction
      • OpenAI Embedder
      • Gemini Embedder
      • Ollama Embedder
      • Voyage AI Embedder
      • Azure OpenAI Embedder
      • Mistral Embedder
      • Fireworks Embedder
      • Together Embedder
      • HuggingFace Embedder
      • Qdrant FastEmbed Embedder
      • SentenceTransformers Embedder
    • Workflows
      • Introduction
      • Session State
      • Streaming
      • Advanced Example - News Report Generator
  • How To
    • Install & Upgrade
    • Upgrade to v2.5.0
Powered by GitBook
LogoLogo

© 2025 Bitca. All rights reserved.

On this page
  • ​Prerequisites
  • ​Example
  • ​Toolkit Params
  • ​Toolkit Functions
Export as PDF
  1. Documentation
  2. Tools

DuckDb

PreviousDalleNextDuckDuckGo

Last updated 4 months ago

DuckDbTools enable an Agent to run SQL and analyze data using DuckDb.

Prerequisites

The following example requires DuckDB library. To install DuckDB, run the following command:

pip install duckdb

For more installation options, please refer to .

Example

The following agent will analyze the movies file using SQL and return the result.

cookbook/tools/duckdb_tools.py

from bitca.agent import Agent
from bitca.tools.duckdb import DuckDbTools

agent = Agent(
    tools=[DuckDbTools()],
    show_tool_calls=True,
    system_prompt="Use this file for Movies data: https://bitca-public.s3.amazonaws.com/demo_data/IMDB-Movie-Data.csv",
)
agent.print_response("What is the average rating of movies?", markdown=True, stream=False)

Toolkit Params

Parameter
Type
Default
Description

db_path

str

-

Specifies the path to the database file.

connection

DuckDBPyConnection

-

Provides an existing DuckDB connection object.

init_commands

List

-

A list of initial SQL commands to run on database connection.

read_only

bool

False

Configures the database connection to be read-only.

config

dict

-

Configuration options for the database connection.

run_queries

bool

True

Determines whether to run SQL queries during the operation.

inspect_queries

bool

False

Enables inspection of SQL queries without executing them.

create_tables

bool

True

Allows creation of tables in the database during the operation.

summarize_tables

bool

True

Enables summarization of table data during the operation.

export_tables

bool

False

Allows exporting tables to external formats during the operation.

Function
Description

show_tables

Function to show tables in the database

describe_table

Function to describe a table

inspect_query

Function to inspect a query and return the query plan. Always inspect your query before running them.

run_query

Function that runs a query and returns the result.

summarize_table

Function to compute a number of aggregates over a table. The function launches a query that computes a number of aggregates over all columns, including min, max, avg, std and approx_unique.

get_table_name_from_path

Get the table name from a path

create_table_from_path

Creates a table from a path

export_table_to_path

Save a table in a desired format (default: parquet). If the path is provided, the table will be saved under that path. Eg: If path is /tmp, the table will be saved as /tmp/table.parquet. Otherwise it will be saved in the current directory

load_local_path_to_table

Load a local file into duckdb

load_local_csv_to_table

Load a local CSV file into duckdb

load_s3_path_to_table

Load a file from S3 into duckdb

load_s3_csv_to_table

Load a CSV file from S3 into duckdb

create_fts_index

Create a full text search index on a table

full_text_search

Full text Search in a table column for a specific text/keyword

Toolkit Functions

​
DuckDB documentation
​
​
​