Skip to content

v0.3.0 - SQLite Database Operations Module

Choose a tag to compare

@jwesleye jwesleye released this 15 Oct 15:07
· 55 commits to main since this release

v0.3.0 - SQLite Database Operations Module

Add comprehensive SQLite database module with 16 functions for safe database operations, schema management, and data migration.

πŸ—„οΈ New Module: Database (16 functions)

Database Operations (5 functions)

  • create_sqlite_database: Create new SQLite database with parent directory creation
  • execute_query: Execute INSERT/UPDATE/DELETE with parameterized queries
  • execute_many: Batch execution in single transaction
  • fetch_all: Return all rows as dictionaries with column names
  • fetch_one: Return single row with found indicator

Schema Management (4 functions)

  • inspect_schema: Complete schema info (tables, columns, types, indexes, row counts)
  • create_table_from_dict: Create table from column nameβ†’type mapping
  • add_column: Add column to existing table with validation
  • create_index: Create indexes with auto-name generation

Safe Query Building (6 functions)

  • build_select_query: Parameterized SELECT with WHERE/ORDER BY/LIMIT
  • build_insert_query: Parameterized INSERT with validation
  • build_update_query: Parameterized UPDATE (requires WHERE clause)
  • build_delete_query: Parameterized DELETE (requires WHERE clause)
  • escape_sql_identifier: Validate table/column names (alphanumeric + underscore)
  • validate_sql_query: Basic SQL injection pattern detection

Migration Helpers (3 functions)

  • export_to_json: Export table data to JSON with UTF-8 encoding
  • import_from_json: Import JSON with optional table clearing
  • backup_database: Full database backup preserving metadata

✨ Key Features

  • Pure stdlib implementation - Uses only sqlite3, zero external dependencies
  • SQL injection prevention - Parameterized queries + identifier validation
  • Google ADK compliance - JSON-serializable returns, no default parameter values
  • Comprehensive error handling - TypeError, ValueError for all inputs
  • Safe by default - UPDATE/DELETE require WHERE clauses to prevent accidents

πŸ§ͺ Testing

  • 81 new tests with comprehensive coverage
  • Total: 532 tests passing in 4.0s (451 β†’ 532)
  • Database module coverage: operations (79%), query_builder (89%), schema (75%), utils (71%)
  • Overall project coverage: 85% (maintains >80% target)

πŸ“¦ Integration

  • Added load_all_database_tools() helper function
  • Updated load_all_tools() to 84 total functions (66 β†’ 84)
  • Updated main __init__.py to export database module

🎯 Quality

  • βœ… 100% ruff compliance maintained
  • βœ… 100% mypy --strict compliance maintained
  • βœ… All functions have comprehensive docstrings
  • βœ… Full type coverage with modern syntax (dict[str, Any])

πŸ“š Use Cases

  • Agent memory: Persistent storage for agent state and conversation history
  • Structured data: Store and query structured information efficiently
  • Data migration: Export/import JSON for backup and transfer
  • Safe queries: Build parameterized queries programmatically

πŸ“– Documentation

  • Updated CHANGELOG.md with v0.3.0 release notes
  • Updated README.md "What's Available Now" section
  • All 16 functions documented with Args/Returns/Raises sections

πŸ”— Full Changelog

See CHANGELOG.md for complete details.


Install: pip install coding-open-agent-tools==0.3.0

Upgrade: pip install --upgrade coding-open-agent-tools

πŸ€– Generated with Claude Code