Skip to main contentü¶úÔ∏èüîó LangChainDocsUse casesIntegrationsAPICommunityChat our docsLangSmithJS/TS DocsSearchCTRLKProvidersAnthropicAWSGoogleMicrosoftOpenAIMoreComponentsLLMsChat modelsDocument loadersDocument transformersText embedding modelsVector storesRetrieversToolsAgents and toolkitsMemoryAWS DynamoDBCassandramemoryMomento CacheMongodDBMot√∂rheadPostgresRedisRemembrallRocksetSingleStoreDBSQL (SQLAlchemy)SQLiteStreamlitUpstash Redis Chat Message HistoryXataZepCallbacksChat loadersComponentsMemorySQL (SQLAlchemy)On this pageSQL (SQLAlchemy)Structured Query Language (SQL) is a domain-specific language used in programming and designed for managing data held in a relational database management system (RDBMS), or for stream processing in a relational data stream management system (RDSMS). It is particularly useful in handling structured data, i.e., data incorporating relations among entities and variables.SQLAlchemy is an open-source SQL toolkit and object-relational mapper (ORM) for the Python programming language released under the MIT License.This notebook goes over a SQLChatMessageHistory class that allows to store chat history in any database supported by SQLAlchemy.Please note that to use it with databases other than SQLite, you will need to install the corresponding database driver.Basic Usage‚ÄãTo use the storage you need to provide only 2 things:Session Id - a unique identifier of the session, like user name, email, chat id etc.Connection string - a string that specifies the database connection. It will be passed to SQLAlchemy create_engine function.Install SQLAlchemy python package.pip install SQLAlchemyfrom langchain.memory.chat_message_histories import SQLChatMessageHistorychat_message_history = SQLChatMessageHistory(    session_id='test_session',    connection_string='sqlite:///sqlite.db')chat_message_history.add_user_message('Hello')chat_message_history.add_ai_message('Hi')chat_message_history.messages    [HumanMessage(content='Hello',
Structured Query Language (SQL) is a domain-specific language used in programming and designed for managing data held in a relational database management system (RDBMS), or for stream processing in a relational data stream management system (RDSMS). It is particularly useful in handling structured data, i.e., data incorporating relations among entities and variables.
Structured Query Language (SQL) is a domain-specific language used in programming and designed for managing data held in a relational database management system (RDBMS), or for stream processing in a relational data stream management system (RDSMS). It is particularly useful in handling structured data, i.e., data incorporating relations among entities and variables. ->: Skip to main contentü¶úÔ∏èüîó LangChainDocsUse casesIntegrationsAPICommunityChat our docsLangSmithJS/TS DocsSearchCTRLKProvidersAnthropicAWSGoogleMicrosoftOpenAIMoreComponentsLLMsChat modelsDocument loadersDocument transformersText embedding modelsVector storesRetrieversToolsAgents and toolkitsMemoryAWS DynamoDBCassandramemoryMomento CacheMongodDBMot√∂rheadPostgresRedisRemembrallRocksetSingleStoreDBSQL (SQLAlchemy)SQLiteStreamlitUpstash Redis Chat Message HistoryXataZepCallbacksChat loadersComponentsMemorySQL (SQLAlchemy)On this pageSQL (SQLAlchemy)Structured Query Language (SQL) is a domain-specific language used in programming and designed for managing data held in a relational database management system (RDBMS), or for stream processing in a relational data stream management system (RDSMS). It is particularly useful in handling structured data, i.e., data incorporating relations among entities and variables.SQLAlchemy is an open-source SQL toolkit and object-relational mapper (ORM) for the Python programming language released under the MIT License.This notebook goes over a SQLChatMessageHistory class that allows to store chat history in any database supported by SQLAlchemy.Please note that to use it with databases other than SQLite, you will need to install the corresponding database driver.Basic Usage‚ÄãTo use the storage you need to provide only 2 things:Session Id - a unique identifier of the session, like user name, email, chat id etc.Connection string - a string that specifies the database connection. It will be passed to SQLAlchemy create_engine function.Install SQLAlchemy python package.pip install SQLAlchemyfrom langchain.memory.chat_message_histories import SQLChatMessageHistorychat_message_history = SQLChatMessageHistory(    session_id='test_session',    connection_string='sqlite:///sqlite.db')chat_message_history.add_user_message('Hello')chat_message_history.add_ai_message('Hi')chat_message_history.messages    [HumanMessage(content='Hello',