You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
This library DatabaseSessionService is showing error #3916
Using these two references, you can address the first two bullet points you mentioned. Additionally, if you are building your application as an HTTP server (for example, with FastAPI), you can leverage the ADK-provided endpoints to create and retrieve sessions.
For a practical overview of the available endpoints, see this Medium post
Regarding the async engines, I haven't tried those right now, however I know this PR that should allow you to use it right now. I will suggest take a look to both the PR and the original issue
python version 3.11.0 im using here your library DatabaseSessionService is not working???????
File "E:\post\auto\tool_agent_init_.py", line 1, in
from . import agent
File "E:\post\auto\tool_agent\agent.py", line 6, in
session_service = DatabaseSessionService(db_url=db_url)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\post.venv\Lib\site-packages\google\adk\sessions\database_session_service.py", line 457, in init
raise ValueError(
ValueError: Fail to load 'tool_agent' module. Failed to create database engine for URL 'sqlite:///./my_agent_data.db'
INFO: 127.0.0.1:58838 - "GET /debug/trace/session/da0c91be-9891-4b10-9190-65a5b68a4c94 HTTP/1.1" 200 OK
changed the title [-]Support PostgreSQL for Conversation / Session Persistence (Documentation & Examples Needed)[/-][+]This library DatabaseSessionService is showing error[/+]on Dec 15, 2025
I'm using google-adk version == 1.21.0. This library DatabaseSessionService is not working.
python version == 3.11.0
Kindly check with this issue
I have also used different version of python like 3.13.0 , 3.20.0 & 3.12.0
But same issue library issue is is shown plz kindly resolve this issue
Hey @nazarcoder123, I did a bit of experimentation around your SQLite issue and revisited my original PostgreSQL setup. In my PostgreSQL configuration, I did not explicitly specify an async dialect (in the url). However, I noticed that using the same approach you are using for SQLite does not work in this case because DatabaseSessionService relies on SQLAlchemy’s create_async_engine.
After digging further, it appears that with PostgreSQL, SQLAlchemy can transparently handle async vs. sync usage. In practice, when calling create_async_engine() with a URL such as postgresql+psycopg://..., SQLAlchemy will automatically select the appropriate async implementation. From the documentation:
Calling create_async_engine() with postgresql+psycopg://... will automatically select the async version.
@DeanChensj I think it may be worth reopening the ticket to document this caveat in the DatabaseSessionService, as it could help avoid confusion. I am happy to take care of it.
you are sharing some very complex things to understand I want to make it clear I have used used this before as well
I have never did so many stuff back. What I am saying is currently in your latest version of google-adk DatabaseSessionService this library is not working. I will share you one link of youtube see that how easily it used to work earlier
link: https://youtu.be/P4VFL9nIaIA?si=258C90DlV13xv56F
watch from 1:14:00
I completely understand the issue. The video you shared is approximately seven months old, and since then this PR — #2889 — changed the implementation to be asynchronous (September 9).
As a result, your db_urlis not working because it now expects an asynchronous SQLite driver.
The only change you need to make is to add +aiosqlite to your db_url variable.
Thanks you it is working.
do you have any repo for postgresql connection how to connect to postgresql i need th entire project. repository If you help me it will be a lot to me. plz
Activity
AlejandroBlanco2001 commentedon Dec 15, 2025
Hey @nazarcoder123, I’m currently using PostgreSQL in a production application with ADK handling short-term memory. I followed the resources below:
Using these two references, you can address the first two bullet points you mentioned. Additionally, if you are building your application as an HTTP server (for example, with FastAPI), you can leverage the ADK-provided endpoints to create and retrieve sessions.
For a practical overview of the available endpoints, see this Medium post
Regarding the async engines, I haven't tried those right now, however I know this PR that should allow you to use it right now. I will suggest take a look to both the PR and the original issue
DeanChensj commentedon Dec 15, 2025
Thanks @AlejandroBlanco2001 for the detailed answer, yes we do support PostgreSQL as session service using DatabaseSessionService.
@nazarcoder123 let us know if you have more questions, thanks!
nazarcoder123 commentedon Dec 15, 2025
python version 3.11.0 im using here your library DatabaseSessionService is not working???????
File "E:\post\auto\tool_agent_init_.py", line 1, in
from . import agent
File "E:\post\auto\tool_agent\agent.py", line 6, in
session_service = DatabaseSessionService(db_url=db_url)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\post.venv\Lib\site-packages\google\adk\sessions\database_session_service.py", line 457, in init
raise ValueError(
ValueError: Fail to load 'tool_agent' module. Failed to create database engine for URL 'sqlite:///./my_agent_data.db'
INFO: 127.0.0.1:58838 - "GET /debug/trace/session/da0c91be-9891-4b10-9190-65a5b68a4c94 HTTP/1.1" 200 OK
[-]Support PostgreSQL for Conversation / Session Persistence (Documentation & Examples Needed)[/-][+]This library DatabaseSessionService is showing error[/+]nazarcoder123 commentedon Dec 15, 2025
AlejandroBlanco2001 commentedon Dec 15, 2025
@nazarcoder123 Can you share details like the ADK version and if you have already the SQLite driver installed?
nazarcoder123 commentedon Dec 16, 2025
I'm using google-adk version == 1.21.0. This library DatabaseSessionService is not working.
python version == 3.11.0
Kindly check with this issue
I have also used different version of python like 3.13.0 , 3.20.0 & 3.12.0
But same issue library issue is is shown plz kindly resolve this issue
AlejandroBlanco2001 commentedon Dec 16, 2025
Hey @nazarcoder123, I did a bit of experimentation around your SQLite issue and revisited my original PostgreSQL setup. In my PostgreSQL configuration, I did not explicitly specify an async dialect (in the url). However, I noticed that using the same approach you are using for SQLite does not work in this case because
DatabaseSessionServicerelies on SQLAlchemy’screate_async_engine.You can see the relevant implementation here
After digging further, it appears that with PostgreSQL, SQLAlchemy can transparently handle async vs. sync usage. In practice, when calling
create_async_engine()with a URL such aspostgresql+psycopg://..., SQLAlchemy will automatically select the appropriate async implementation. From the documentation:Relevant references:
https://docs.sqlalchemy.org/en/20/dialects/sqlite.html#transactions-with-sqlite-and-the-sqlite3-driver
https://docs.sqlalchemy.org/en/21/dialects/postgresql.html#dialect-postgresql-psycopg-connect
So, to make it work for SQLite you must do something like:
@DeanChensj I think it may be worth reopening the ticket to document this caveat in the
DatabaseSessionService, as it could help avoid confusion. I am happy to take care of it.nazarcoder123 commentedon Dec 16, 2025
you are sharing some very complex things to understand I want to make it clear I have used used this before as well
I have never did so many stuff back. What I am saying is currently in your latest version of google-adk DatabaseSessionService this library is not working. I will share you one link of youtube see that how easily it used to work earlier
link: https://youtu.be/P4VFL9nIaIA?si=258C90DlV13xv56F
watch from 1:14:00
AlejandroBlanco2001 commentedon Dec 16, 2025
I completely understand the issue. The video you shared is approximately seven months old, and since then this PR — #2889 — changed the implementation to be asynchronous (September 9).
As a result, your
db_urlis not working because it now expects an asynchronous SQLite driver.The only change you need to make is to add
+aiosqliteto your db_url variable.nazarcoder123 commentedon Dec 16, 2025
Thanks you it is working.
do you have any repo for postgresql connection how to connect to postgresql i need th entire project. repository If you help me it will be a lot to me. plz
docs: Add PostgreSQL session storage sample and documentation
docs: Add PostgreSQL session storage sample and documentation
AlejandroBlanco2001 commentedon Dec 16, 2025
Doc update: google/adk-docs#1077
docs: Add PostgreSQL session storage sample and documentation
docs: Add PostgreSQL session storage sample and documentation
docs: Add PostgreSQL session storage sample and documentation