{"id":50839867,"url":"https://github.com/anmolg1997/adk-database-memory","last_synced_at":"2026-06-14T06:05:10.360Z","repository":{"id":352805265,"uuid":"1216704332","full_name":"anmolg1997/adk-database-memory","owner":"anmolg1997","description":"SQL-backed memory service for the Google Agent Development Kit (ADK). SQLite, PostgreSQL, MySQL/MariaDB via SQLAlchemy async.","archived":false,"fork":false,"pushed_at":"2026-04-21T07:30:22.000Z","size":23,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-21T08:38:54.298Z","etag":null,"topics":["adk","agent-development-kit","agents","google-adk","llm","memory","postgres","python","sqlalchemy","sqlite"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/adk-database-memory/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anmolg1997.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-21T06:47:59.000Z","updated_at":"2026-04-21T07:30:26.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/anmolg1997/adk-database-memory","commit_stats":null,"previous_names":["anmolg1997/adk-database-memory"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/anmolg1997/adk-database-memory","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anmolg1997%2Fadk-database-memory","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anmolg1997%2Fadk-database-memory/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anmolg1997%2Fadk-database-memory/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anmolg1997%2Fadk-database-memory/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anmolg1997","download_url":"https://codeload.github.com/anmolg1997/adk-database-memory/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anmolg1997%2Fadk-database-memory/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34310805,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-14T02:00:07.365Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["adk","agent-development-kit","agents","google-adk","llm","memory","postgres","python","sqlalchemy","sqlite"],"created_at":"2026-06-14T06:05:08.349Z","updated_at":"2026-06-14T06:05:10.351Z","avatar_url":"https://github.com/anmolg1997.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# adk-database-memory\n\nSQL-backed memory service for the [Google Agent Development Kit (ADK)](https://github.com/google/adk-python).\n\nDrop-in durable replacement for `InMemoryMemoryService`. Works with any async SQLAlchemy dialect: SQLite, PostgreSQL, MySQL/MariaDB, and more.\n\nListed in the [official ADK integrations catalog](https://google.github.io/adk-docs/integrations/database-memory/).\n\n[![PyPI](https://img.shields.io/pypi/v/adk-database-memory.svg?cacheSeconds=300)](https://pypi.org/project/adk-database-memory/)\n[![Python](https://img.shields.io/pypi/pyversions/adk-database-memory.svg?cacheSeconds=300)](https://pypi.org/project/adk-database-memory/)\n[![CI](https://github.com/anmolg1997/adk-database-memory/actions/workflows/ci.yml/badge.svg)](https://github.com/anmolg1997/adk-database-memory/actions/workflows/ci.yml)\n[![Downloads](https://img.shields.io/pypi/dm/adk-database-memory.svg?cacheSeconds=300)](https://pypi.org/project/adk-database-memory/)\n[![ADK Docs](https://img.shields.io/badge/ADK_Docs-Listed-4285F4?logo=google\u0026logoColor=white)](https://google.github.io/adk-docs/integrations/database-memory/)\n[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](./LICENSE)\n\n## Why\n\nADK ships an in-memory memory service for development and Vertex AI Memory Bank for production on GCP. If you want durable memory on your own Postgres / SQLite / MySQL, there was no built-in option. This package fills that gap with the same `BaseMemoryService` contract, so you can swap it in without changing agent code.\n\n## Install\n\n```bash\npip install adk-database-memory[sqlite]       # SQLite (via aiosqlite)\npip install adk-database-memory[postgres]     # PostgreSQL (via asyncpg)\npip install adk-database-memory[mysql]        # MySQL / MariaDB (via aiomysql)\n```\n\nThe base install does not pull any database driver. Pick the extra that matches your backend, or install your own async SQLAlchemy driver separately.\n\n## Examples\n\nThree runnable scripts in [`examples/`](./examples/):\n\n- `quickstart_sqlite.py` - smallest end-to-end usage\n- `with_runner.py` - plug into an ADK `Runner` with the `load_memory` tool\n- `multi_user_search.py` - per-user isolation demo\n\n## Quick start\n\n```python\nimport asyncio\nfrom adk_database_memory import DatabaseMemoryService\n\nasync def main():\n    # SQLite, zero-config\n    async with DatabaseMemoryService(\"sqlite+aiosqlite:///memory.db\") as memory:\n        await memory.add_session_to_memory(session)\n\n        result = await memory.search_memory(\n            app_name=\"my_app\",\n            user_id=\"u1\",\n            query=\"what did we decide about the pricing model?\",\n        )\n        for entry in result.memories:\n            print(entry.author, entry.timestamp, entry.content)\n\nasyncio.run(main())\n```\n\n### With an ADK `Runner`\n\n```python\nfrom google.adk.runners import Runner\nfrom adk_database_memory import DatabaseMemoryService\n\nmemory = DatabaseMemoryService(\n    \"postgresql+asyncpg://user:pass@localhost:5432/agentdb\"\n)\n\nrunner = Runner(\n    app_name=\"my_app\",\n    agent=my_agent,\n    memory_service=memory,\n    session_service=session_service,\n)\n```\n\n## Supported backends\n\n| Backend | URL example | Extra |\n|---|---|---|\n| SQLite | `sqlite+aiosqlite:///memory.db` | `[sqlite]` |\n| SQLite (in-memory) | `sqlite+aiosqlite:///:memory:` | `[sqlite]` |\n| PostgreSQL | `postgresql+asyncpg://user:pass@host/db` | `[postgres]` |\n| MySQL / MariaDB | `mysql+aiomysql://user:pass@host/db` | `[mysql]` |\n| Any async SQLAlchemy dialect | depends on driver | bring your own |\n\n## API\n\nThe service implements `google.adk.memory.base_memory_service.BaseMemoryService`, so it exposes the same three methods used everywhere else in ADK:\n\n- `add_session_to_memory(session)` - index every event of a session.\n- `add_events_to_memory(app_name, user_id, events, ...)` - index a delta slice of events (useful for streaming ingestion).\n- `search_memory(app_name, user_id, query)` - return `MemoryEntry`s whose indexed keywords overlap with the query, scoped to the given app and user.\n\nConstructor:\n\n```python\nDatabaseMemoryService(\n    db_url: str,\n    *,\n    stop_words: set[str] | None = None,   # override the default English stop-words list\n    **engine_kwargs,                       # forwarded to create_async_engine\n)\n```\n\nLifecycle:\n\n```python\nasync with DatabaseMemoryService(db_url) as memory:\n    ...\n# equivalent to:\nmemory = DatabaseMemoryService(db_url)\ntry:\n    ...\nfinally:\n    await memory.close()\n```\n\n## How it works\n\n- On first write, a single table `adk_memory_entries` is created (lazy, with an async double-checked lock) with an index on `(app_name, user_id)`.\n- Each event's text content is lower-cased, tokenized (`[A-Za-z]+`), and filtered against the stop-words set to produce a keyword bag.\n- Search extracts keywords from the query the same way and returns rows where the bags overlap, scoped by `app_name` and `user_id`, then de-duplicates on `(author, text, timestamp)`.\n- JSON content is stored as `JSONB` on PostgreSQL, `LONGTEXT` on MySQL, and `TEXT` on SQLite/others via a `DynamicJSON` type decorator.\n\nThis is intentionally the same keyword-matching approach as the in-memory and Firestore memory services in ADK; it is a durable, zero-infra starting point, not a semantic retriever. If you need embedding-based recall, pair this package with Vertex AI Memory Bank or a vector store.\n\n## Development\n\n```bash\ngit clone https://github.com/anmolg1997/adk-database-memory\ncd adk-database-memory\npip install -e \".[dev]\"\npytest\nruff check .\nmypy src\n```\n\n## License\n\nApache 2.0 - see [LICENSE](./LICENSE).\n\n## Related\n\n- [Official ADK docs listing](https://google.github.io/adk-docs/integrations/database-memory/) - integration page on `google.github.io/adk-docs`.\n- [google/adk-python](https://github.com/google/adk-python) - core Agent Development Kit.\n- [ADK Memory overview](https://google.github.io/adk-docs/sessions/memory/) - background on how ADK uses memory services.\n- [`FirestoreSessionService` (PR #5088)](https://github.com/google/adk-python/pull/5088) - the sibling Firestore session service this memory service's keyword-index approach mirrors.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanmolg1997%2Fadk-database-memory","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanmolg1997%2Fadk-database-memory","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanmolg1997%2Fadk-database-memory/lists"}