{"id":46807,"date":"2024-07-26T00:00:00","date_gmt":"2024-07-26T07:00:00","guid":{"rendered":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/blog\/crud-operations-on-griddb-with-langchain\/"},"modified":"2025-11-13T12:57:03","modified_gmt":"2025-11-13T20:57:03","slug":"crud-operations-on-griddb-with-langchain","status":"publish","type":"post","link":"https:\/\/griddb.net\/en\/blog\/crud-operations-on-griddb-with-langchain\/","title":{"rendered":"CRUD Operations on GridDB with LangChain"},"content":{"rendered":"<p>This article explains how to use natural language queries to perform CRUD (create, read, update, and delete) operations on <a href=\"https:\/\/griddb.net\/\">GridDB<\/a>. You will use the Python <a href=\"https:\/\/python.langchain.com\/v0.2\/docs\/introduction\/\">LangChain<\/a> module and the <a href=\"https:\/\/openai.com\/index\/hello-gpt-4o\/\">OpenAI GPT-4o LLM<\/a> (Large Language Model to convert natural language queries to GridDB queries and perform various operations on GridDB.<\/p>\n<p>GridDB is a robust NoSQL database designed to handle large volumes of real-time data. It excels in scalability and provides advanced in-memory processing capabilities and efficient time series data management. These features make GridDB well-suited for Internet of Things (IoT) and big data applications.<\/p>\n<h2>Source code And Jupyter Notebook<\/h2>\n<p>You can find the source code (jupyter notebook) from our github repo:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">$ git clone https:\/\/github.com\/griddbnet\/Blogs.git --branch crud_with_langchain<\/code><\/pre>\n<\/div>\n<h2>Prerequisites<\/h2>\n<p>You need to install the GridDB C Client and the GridDB Python client before you can connect your Python application to GridDB. Follow the instructions on the <a href=\"https:\/\/pypi.org\/project\/griddb-python\/\">GridDB Python Package Index (Pypi) page<\/a> to install these clients.<\/p>\n<p>We will use the OpenAI GPT-4o large language model (LLM) to convert natural language queries to GridDB queries. To use the GPT-4o model, you must <a href=\"https:\/\/platform.openai.com\/login?launch\">create an account with OpenAI<\/a> and get your API key. Finally, you must install the following libraries to access OpenAI API from the LangChain framework.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">!pip install langchain\n!pip install langchain-core\n!pip install langchain-openai<\/code><\/pre>\n<\/div>\n<p><strong>Note:<\/strong> If you do not want to use GPT-4o, you can also use any other LangChain-supported LLM. The process remains the same, except that you will have to install the corresponding libraries.<\/p>\n<p>The script below imports the libraries you will need to run the code in this blog.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-python\">import griddb_python as griddb\nimport pandas as pd\nfrom langchain_openai import ChatOpenAI\nfrom langchain_core.prompts import ChatPromptTemplate\nfrom langchain_core.pydantic_v1 import BaseModel, Field\nfrom typing import List, Dict<\/code><\/pre>\n<\/div>\n<h2>Creating a Connection with GridDB<\/h2>\n<p>The first step is to create a connection with GridDB. To do so, you must create a GridDB <code>StoreFactory<\/code> instance using the <code>get_instance()<\/code> method. Next, you need to pass your database host, cluster name, admin, and passwords to the <code>get_store()<\/code> method. This method returns a GridDB store object you can use to perform CRUD operations on GridDB. The following script creates a GridDB connection and tests it by retrieving a random container.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-python\">factory = griddb.StoreFactory.get_instance()\n\nDB_HOST = \"127.0.0.1:10001\"\nDB_CLUSTER = \"myCluster\"\nDB_USER = \"admin\"\nDB_PASS = \"admin\"\n\ntry:\n    gridstore = factory.get_store(\n        notification_member = DB_HOST,\n        cluster_name = DB_CLUSTER,\n        username = DB_USER,\n        password = DB_PASS\n    )\n\n    container1 = gridstore.get_container(\"container1\")\n    if container1 == None:\n        print(\"Container does not exist\")\n    print(\"Successfully connected to GridDB\")\n\nexcept griddb.GSException as e:\n    for i in range(e.get_error_stack_size()):\n        print(\"[\", i, \"]\")\n        print(e.get_error_code(i))\n        print(e.get_location(i))\n        print(e.get_message(i))<\/code><\/pre>\n<\/div>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">Container does not exist\nSuccessfully connected to GridDB<\/code><\/pre>\n<\/div>\n<p>Once the connection is established, you can use natural language queries with the LangChain framework to perform CRUD operations on GridDB, as you will see in the upcoming sections.<\/p>\n<h2>Inserting Data with Natural Language Commands Using LangChain<\/h2>\n<p>As discussed, we will use the OpenAI GPT-4o LLM to parse natural language queries and convert them into GridDB queries. To do so, you need to create an object of the <code>ChatOpenAI<\/code> class and pass your OpenAI API key, temperature, and model name to it.<\/p>\n<p>Higher temperatures allow the model to be more creative. However, we want the model to be more accurate, hence we set the temperature to 0.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-python\">llm = ChatOpenAI(api_key=\"YOUR_OPENAI_API_KEY\",\n                 temperature = 0,\n                model_name = \"gpt-4o\")\n<\/code><\/pre>\n<\/div>\n<p>We will adopt the following approach to convert natural language queries to GridDB queries.<\/p>\n<ol>\n<li>From natural language queries, using LLMs, extract entities needed to execute GridDB queries.<\/li>\n<li>Embed these entities into GridDB queries to perform CRUD operations on GridDB. <\/li>\n<\/ol>\n<p>For example, to execute INSERT queries on GridDB containers, we need data column names, column types, column values, and container names. To extract these values as entities from natural language queries, we will first create a Pydantic <code>BaseModel<\/code> child class and add these entities as attributes. Based on the description of the class attributes, LLM will populate these attributes with data extracted from a natural language query. The following script creates a pydantic <code>InsertData<\/code> class for extracting insertion entities.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-python\">class InsertData(BaseModel):\n    column_names: List[str]= Field(description=\"All the column names from the structured data\")\n    column_types: List[str] = Field(description=\"All the column types from the structured data\")\n    column_values: List[List[str]] = Field(description=\"All the column values from the structured data\")\n    container_name: str = Field(description=\"Name of container extracted from the user query\")<\/code><\/pre>\n<\/div>\n<p>Next, we will create a LangChain chain that tells the LLM about the information it must extract from the natural language. We use the <code>with_structured_output()<\/code> method and pass the <code>InsertData<\/code> pydantic class we created earlier. The LLM will return a dictionary populated with the attributes described in the <code>InsertData<\/code> class.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-python\">system_command = \"\"\" You are an expert who extracts structure from natural language queries that must be converted to database queries.\nParse the user input query and extract the container name and column names along with their types from the user query and the user records.\nThe types should be parsed as STRING, LONG, FLOAT, INTEGER\n\"\"\"\n\nuser_prompt = ChatPromptTemplate.from_messages([\n    (\"system\", system_command ),\n    (\"user\", \"{input}\")\n])\n\ninsert_chain = user_prompt | llm.with_structured_output(InsertData)<\/code><\/pre>\n<\/div>\n<p>To test the LLM, let&#8217;s create a natural language query that inserts data into a database. We pass this query to the <code>insert_chain<\/code> we created in the previous script and print the extracted entities.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-python\">user_query = \"\"\"\n\nInsert the following student records into the student_data container.\n\nName = Michael\nAge = 10\nGender = Male\nGrade = A\n\n\nName = Sara\nAge = 11\nGender = Female\nGrade = C\n\nName = Nick\nAge = 9\nGender = Male\nGrade = B\n\n\"\"\"\nuser_data = insert_chain.invoke({\"input\": user_query})\n\nprint(user_data.column_names)\nprint(user_data.column_types)\nprint(user_data.column_values)\nprint(user_data.container_name)<\/code><\/pre>\n<\/div>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/griddb.net\/wp-content\/uploads\/2024\/09\/img1-structured-llm-output.png\"><img fetchpriority=\"high\" decoding=\"async\" src=\"https:\/\/griddb.net\/wp-content\/uploads\/2024\/09\/img1-structured-llm-output.png\" alt=\"\" width=\"896\" height=\"100\" class=\"aligncenter size-full wp-image-30222\" srcset=\"\/wp-content\/uploads\/2024\/09\/img1-structured-llm-output.png 896w, \/wp-content\/uploads\/2024\/09\/img1-structured-llm-output-300x33.png 300w, \/wp-content\/uploads\/2024\/09\/img1-structured-llm-output-768x86.png 768w, \/wp-content\/uploads\/2024\/09\/img1-structured-llm-output-600x67.png 600w\" sizes=\"(max-width: 896px) 100vw, 896px\" \/><\/a><\/p>\n<p>From the above output, you can see that the LLM has successfully extracted the entities.<\/p>\n<p>The rest of the process is straightforward. We embed the extracted entities in the script that inserts data into a GridDB container.<\/p>\n<p>The script below defines two helper functions. The <code>convert_list_of_types()<\/code> function converts the extracted string column types to GridDB column types.<\/p>\n<p>Similarly, the column values extracted by an LLM will be in string format. However, some of these values will be integers. We will try to convert the string values to integer format to match the column type. The <code>try_convert_to_int()<\/code> function does this.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-python\">str_to_griddb_type = {\n    \"LONG\": griddb.Type.LONG,\n    \"INTEGER\": griddb.Type.INTEGER,\n    \"STRING\": griddb.Type.STRING,\n    \"FLOAT\": griddb.Type.FLOAT,\n    # Add other types as needed\n}\n\n# Function to convert a list of string types to GridDB types\ndef convert_list_of_types(type_list):\n    try:\n        return [str_to_griddb_type[type_str] for type_str in type_list]\n    except KeyError as e:\n        raise ValueError(f\"Unsupported type string: {e.args[0]}\")\n\ndef try_convert_to_int(value):\n    try:\n        return int(value)\n    except ValueError:\n        return value\n<\/code><\/pre>\n<\/div>\n<p>We are now ready to convert a natural language query into a GridDB data insertion query. To do so, we will define the <code>insert_records()<\/code> function as shown in the script below. This function accepts a natural language query, extracts entities from the query using a GPT-4o LLM from LangChain, embeds the entities into the GridDB query, and inserts the data into GridDB.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-python\">def insert_records(query):\n    user_data = insert_chain.invoke({\"input\": query})\n\n    container_name = user_data.container_name\n    column_names = user_data.column_names\n    \n    column_values = user_data.column_values\n    column_values  = [[try_convert_to_int(item) for item in sublist] for sublist in column_values]\n\n    column_types = user_data.column_types\n    griddb_type = convert_list_of_types(column_types)\n\n    container_columns = []\n    for column_name, dtype in zip(column_names, griddb_type):\n        container_columns.append([column_name, dtype])\n\n    container_info = griddb.ContainerInfo(container_name,\n                                          container_columns,\n                                          griddb.ContainerType.COLLECTION, True)\n\n    try:\n        cont = gridstore.put_container(container_info)\n        for row in column_values:\n            cont.put(row)\n        print(\"All rows have been successfully stored in the GridDB container.\")\n    \n    except griddb.GSException as e:\n        for i in range(e.get_error_stack_size()):\n            print(\"[\", i, \"]\")\n            print(e.get_error_code(i))\n            print(e.get_location(i))\n            print(e.get_message(i))\n            \ninsert_records(user_query)<\/code><\/pre>\n<\/div>\n<p><strong>Output:<\/strong><\/p>\n<pre><code>All rows have been successfully stored in the GridDB container.\n<\/code><\/pre>\n<p>If you see the above message, the data is successfully inserted. Let&#8217;s now see how to select this data.<\/p>\n<h2>Selecting Data<\/h2>\n<p>The process of selecting data using natural language queries is similar. We will create a pydantic class to extract the container name and the select query from the natural language query. We create a LangChain chain and tell the LLM that it should convert the user command to SQL query.<\/p>\n<p>The following script performs these steps.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-python\">class SelectData(BaseModel):\n    container_name: str = Field(description=\"the container name from the user query\")\n    query:str = Field(description=\"natural language converted to SELECT query\")\n\n\nsystem_command = \"\"\" \nConvert user commands into SQL queries for Griddb.\n\"\"\"\n\nuser_prompt = ChatPromptTemplate.from_messages([\n    (\"system\", system_command),\n    (\"user\", \"{input}\")\n])\n\nselect_chain = user_prompt | llm.with_structured_output(SelectData)<\/code><\/pre>\n<\/div>\n<p>Next, we will define a function <code>select_records<\/code> that accepts a natural language query, converts it into a SELECT query using the LLM, and retrieves records from GridDB.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-python\">def select_records(query):\n\n    select_data = select_chain.invoke(query)\n    container_name = select_data.container_name\n    select_query = select_data.query\n    \n    result_container = gridstore.get_container(container_name)\n    query = result_container.query(select_query)\n    rs = query.fetch()\n    result_data = rs.fetch_rows()\n    return result_data\n\n\nselect_records(\"Give me student records from student_data container where Age is greater than or equal to 10\")<\/code><\/pre>\n<\/div>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/griddb.net\/wp-content\/uploads\/2024\/09\/img2-selecting-data-from-griddb.png\"><img decoding=\"async\" src=\"https:\/\/griddb.net\/wp-content\/uploads\/2024\/09\/img2-selecting-data-from-griddb.png\" alt=\"\" width=\"256\" height=\"119\" class=\"aligncenter size-full wp-image-30223\" \/><\/a><\/p>\n<p>From the above output, you can see that the LLM generated a SELECT query containing the WHERE clause and only retrieved student records where the <code>Age<\/code> column values are greater than or equal to 10.<\/p>\n<h2>Update Data<\/h2>\n<p>The approach remains the same for updating records with natural language. We create a pydantic class <code>UpdateData<\/code> which extracts the container name, the records to select, the column name, and the updated value.<\/p>\n<p>Next, we create an <code>update_chain<\/code> that tells the LLM to retrieve the necessary entities for updating records.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-python\">class UpdateData(BaseModel):\n    container_name: str = Field(description=\"the container name from the user query\")\n    select_query:str = Field(description=\"natural language converted to SELECT query\")\n    column_name: str = Field(description=\"name of the column to be updated\")\n    column_value: str = Field(description=\"Column value to be updated\")\n\n\nsystem_command = \"\"\" \nConvert user commands into SQL query as follows. If the user enters an Update query, return the following:\n1. The name of the container\n2. A SELECT query to query records in the update statement.\n3. The name of the column to be updated. \n4. The new value for the column. \n\"\"\"\n\nuser_prompt = ChatPromptTemplate.from_messages([\n    (\"system\", system_command),\n    (\"user\", \"{input}\")\n])\n\nupdate_chain = user_prompt | llm.with_structured_output(UpdateData)<\/code><\/pre>\n<\/div>\n<p>We can then define a function <code>update_records()<\/code> that converts natural language user query into a GridDB query for updating records.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-python\">def update_records(query):\n\n    update_data = update_chain.invoke(query)\n\n    result_container = gridstore.get_container(update_data.container_name)\n    result_container.set_auto_commit(False)\n    query = result_container.query(update_data.select_query)\n    rs = query.fetch(True)\n\n    select_data = select_records(f\"Select all records from {update_data.container_name}\")\n    \n    if rs.has_next():\n        data = rs.next()\n        column_index = select_data.columns.get_loc(update_data.column_name)\n    \n        data[column_index] = int(update_data.column_value)\n        rs.update(data)\n    \n    result_container.commit()\n    print(\"record updated successfully.\")\n\n\nupdate_records(\"Update the age of the students in the student_data container to 11 where Age is greater than or equal to 10\")\n\nYou can select the following records to see if the data has been updated. \n\nselect_records(f\"Select all records from student_data container\")<\/code><\/pre>\n<\/div>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/griddb.net\/wp-content\/uploads\/2024\/09\/img3-selecting-updated-data-from-griddb.png\"><img decoding=\"async\" src=\"https:\/\/griddb.net\/wp-content\/uploads\/2024\/09\/img3-selecting-updated-data-from-griddb.png\" alt=\"\" width=\"257\" height=\"138\" class=\"aligncenter size-full wp-image-30220\" \/><\/a><\/p>\n<p>The above output shows updated records.<\/p>\n<h2>Delete Data<\/h2>\n<p>Finally, the process for deleting records also remains similar. We create a pydantic <code>DeleteData<\/code> class that extracts the container and the records to delete from a natural language user query.<\/p>\n<p>We create a <code>delete_chain<\/code> that tells the LLM to return a select statement that retrieves records the user wants to delete.<\/p>\n<p>For example, running the following script returns a select query for deleting student records where students&#8217; age is greater than 10.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-python\">class DeleteData(BaseModel):\n    select_query:str = Field(description=\"natural language converted to SELECT query\")\n    container_name: str = Field(description=\"the container name from the user query\")\n\n\nsystem_command = \"\"\" \nGiven a user natural language query, return an SQL select statement which selects the records that user wants to delete\n\"\"\"\n\nuser_prompt = ChatPromptTemplate.from_messages([\n    (\"system\", system_command),\n    (\"user\", \"{input}\")\n])\n\ndelete_chain = user_prompt | llm.with_structured_output(DeleteData)\n\nresult_chain = delete_chain.invoke(\"Delete all records from student_data container whose Age is greater than 10\")\nprint(result_chain)\n<\/code><\/pre>\n<\/div>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-python\">select_query='SELECT * FROM student_data WHERE Age > 10' container_name='student_data'\n<\/code><\/pre>\n<\/div>\n<p>Next, we define the <code>delete_records()<\/code> method that accepts a natural language query, extracts entities for deleting records using the <code>delete_chain<\/code>, and deletes records from the GridDB.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-python\">def delete_records(query):\n\n    update_data = update_chain.invoke(query)\n\n    result_container = gridstore.get_container(update_data.container_name)\n\n    result_container.set_auto_commit(False)\n\n    query = result_container.query(update_data.select_query)\n    \n    rs = query.fetch(True)\n    \n    while rs.has_next():\n        data = rs.next()\n        rs.remove()\n    \n    \n    result_container.commit()\n    print(\"Records deleted successfully\")\n\ndelete_records(\"Delete all records from student_data container whose Age is greater than 10\")\n<\/code><\/pre>\n<\/div>\n<p>You can select all records to confirm whether the records have been deleted or not.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-python\">select_records(f\"Select all records from student_data container\")<\/code><\/pre>\n<\/div>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/griddb.net\/wp-content\/uploads\/2024\/09\/img4-records-after-deletion.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/griddb.net\/wp-content\/uploads\/2024\/09\/img4-records-after-deletion.png\" alt=\"\" width=\"273\" height=\"104\" class=\"aligncenter size-full wp-image-30221\" \/><\/a><\/p>\n<h2>Conclusion<\/h2>\n<p>In this article, you learned how to perform CRUD operations on GridDB using natural language queries with the LangChain framework and the OpenAI GPT-4o LLM. We explored how to connect Python to GridDB, insert data into GridDB containers, and select, update, and delete records using natural language commands. GridDB is a highly scalable open-source database designed to efficiently manage large volumes of real-time data. It excels at handling IoT and time-series data, making it an excellent choice for applications requiring advanced in-memory processing capabilities.<\/p>\n<p>If you have any questions or queries related to GridDB, feel free to create a post on Stack Overflow. Remember to use the <code>griddb<\/code> tag so our engineers can respond promptly.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This article explains how to use natural language queries to perform CRUD (create, read, update, and delete) operations on GridDB. You will use the Python LangChain module and the OpenAI GPT-4o LLM (Large Language Model to convert natural language queries to GridDB queries and perform various operations on GridDB. GridDB is a robust NoSQL database [&hellip;]<\/p>\n","protected":false},"author":41,"featured_media":30219,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[121],"tags":[],"class_list":["post-46807","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>CRUD Operations on GridDB with LangChain | GridDB: Open Source Time Series Database for IoT<\/title>\n<meta name=\"description\" content=\"This article explains how to use natural language queries to perform CRUD (create, read, update, and delete) operations on GridDB. You will use the Python\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/griddb.net\/en\/blog\/crud-operations-on-griddb-with-langchain\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"CRUD Operations on GridDB with LangChain | GridDB: Open Source Time Series Database for IoT\" \/>\n<meta property=\"og:description\" content=\"This article explains how to use natural language queries to perform CRUD (create, read, update, and delete) operations on GridDB. You will use the Python\" \/>\n<meta property=\"og:url\" content=\"https:\/\/griddb.net\/en\/blog\/crud-operations-on-griddb-with-langchain\/\" \/>\n<meta property=\"og:site_name\" content=\"GridDB: Open Source Time Series Database for IoT\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/griddbcommunity\/\" \/>\n<meta property=\"article:published_time\" content=\"2024-07-26T07:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-11-13T20:57:03+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/griddb.net\/wp-content\/uploads\/2024\/09\/Gemini_Generated_Image_j8dq2uj8dq2uj8dq.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1536\" \/>\n\t<meta property=\"og:image:height\" content=\"1536\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"griddb-admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@GridDBCommunity\" \/>\n<meta name=\"twitter:site\" content=\"@GridDBCommunity\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"griddb-admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"12 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/griddb.net\/en\/blog\/crud-operations-on-griddb-with-langchain\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/griddb.net\/en\/blog\/crud-operations-on-griddb-with-langchain\/\"},\"author\":{\"name\":\"griddb-admin\",\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#\/schema\/person\/4fe914ca9576878e82f5e8dd3ba52233\"},\"headline\":\"CRUD Operations on GridDB with LangChain\",\"datePublished\":\"2024-07-26T07:00:00+00:00\",\"dateModified\":\"2025-11-13T20:57:03+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/griddb.net\/en\/blog\/crud-operations-on-griddb-with-langchain\/\"},\"wordCount\":1237,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#organization\"},\"image\":{\"@id\":\"https:\/\/griddb.net\/en\/blog\/crud-operations-on-griddb-with-langchain\/#primaryimage\"},\"thumbnailUrl\":\"\/wp-content\/uploads\/2024\/09\/Gemini_Generated_Image_j8dq2uj8dq2uj8dq.jpg\",\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/griddb.net\/en\/blog\/crud-operations-on-griddb-with-langchain\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/griddb.net\/en\/blog\/crud-operations-on-griddb-with-langchain\/\",\"url\":\"https:\/\/griddb.net\/en\/blog\/crud-operations-on-griddb-with-langchain\/\",\"name\":\"CRUD Operations on GridDB with LangChain | GridDB: Open Source Time Series Database for IoT\",\"isPartOf\":{\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/griddb.net\/en\/blog\/crud-operations-on-griddb-with-langchain\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/griddb.net\/en\/blog\/crud-operations-on-griddb-with-langchain\/#primaryimage\"},\"thumbnailUrl\":\"\/wp-content\/uploads\/2024\/09\/Gemini_Generated_Image_j8dq2uj8dq2uj8dq.jpg\",\"datePublished\":\"2024-07-26T07:00:00+00:00\",\"dateModified\":\"2025-11-13T20:57:03+00:00\",\"description\":\"This article explains how to use natural language queries to perform CRUD (create, read, update, and delete) operations on GridDB. You will use the Python\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/griddb.net\/en\/blog\/crud-operations-on-griddb-with-langchain\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/griddb.net\/en\/blog\/crud-operations-on-griddb-with-langchain\/#primaryimage\",\"url\":\"\/wp-content\/uploads\/2024\/09\/Gemini_Generated_Image_j8dq2uj8dq2uj8dq.jpg\",\"contentUrl\":\"\/wp-content\/uploads\/2024\/09\/Gemini_Generated_Image_j8dq2uj8dq2uj8dq.jpg\",\"width\":1536,\"height\":1536},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#website\",\"url\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/\",\"name\":\"GridDB: Open Source Time Series Database for IoT\",\"description\":\"GridDB is an open source time-series database with the performance of NoSQL and convenience of SQL\",\"publisher\":{\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#organization\",\"name\":\"Fixstars\",\"url\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/griddb.net\/wp-content\/uploads\/2019\/04\/fixstars_logo_web_tagline.png\",\"contentUrl\":\"https:\/\/griddb.net\/wp-content\/uploads\/2019\/04\/fixstars_logo_web_tagline.png\",\"width\":200,\"height\":83,\"caption\":\"Fixstars\"},\"image\":{\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/griddbcommunity\/\",\"https:\/\/x.com\/GridDBCommunity\",\"https:\/\/www.linkedin.com\/company\/griddb-by-toshiba\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#\/schema\/person\/4fe914ca9576878e82f5e8dd3ba52233\",\"name\":\"griddb-admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/5bceca1cafc06886a7ba873e2f0a28011a1176c4dea59709f735b63ae30d0342?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/5bceca1cafc06886a7ba873e2f0a28011a1176c4dea59709f735b63ae30d0342?s=96&d=mm&r=g\",\"caption\":\"griddb-admin\"},\"url\":\"https:\/\/griddb.net\/en\/author\/griddb-admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"CRUD Operations on GridDB with LangChain | GridDB: Open Source Time Series Database for IoT","description":"This article explains how to use natural language queries to perform CRUD (create, read, update, and delete) operations on GridDB. You will use the Python","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/griddb.net\/en\/blog\/crud-operations-on-griddb-with-langchain\/","og_locale":"en_US","og_type":"article","og_title":"CRUD Operations on GridDB with LangChain | GridDB: Open Source Time Series Database for IoT","og_description":"This article explains how to use natural language queries to perform CRUD (create, read, update, and delete) operations on GridDB. You will use the Python","og_url":"https:\/\/griddb.net\/en\/blog\/crud-operations-on-griddb-with-langchain\/","og_site_name":"GridDB: Open Source Time Series Database for IoT","article_publisher":"https:\/\/www.facebook.com\/griddbcommunity\/","article_published_time":"2024-07-26T07:00:00+00:00","article_modified_time":"2025-11-13T20:57:03+00:00","og_image":[{"width":1536,"height":1536,"url":"https:\/\/griddb.net\/wp-content\/uploads\/2024\/09\/Gemini_Generated_Image_j8dq2uj8dq2uj8dq.jpg","type":"image\/jpeg"}],"author":"griddb-admin","twitter_card":"summary_large_image","twitter_creator":"@GridDBCommunity","twitter_site":"@GridDBCommunity","twitter_misc":{"Written by":"griddb-admin","Est. reading time":"12 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/griddb.net\/en\/blog\/crud-operations-on-griddb-with-langchain\/#article","isPartOf":{"@id":"https:\/\/griddb.net\/en\/blog\/crud-operations-on-griddb-with-langchain\/"},"author":{"name":"griddb-admin","@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#\/schema\/person\/4fe914ca9576878e82f5e8dd3ba52233"},"headline":"CRUD Operations on GridDB with LangChain","datePublished":"2024-07-26T07:00:00+00:00","dateModified":"2025-11-13T20:57:03+00:00","mainEntityOfPage":{"@id":"https:\/\/griddb.net\/en\/blog\/crud-operations-on-griddb-with-langchain\/"},"wordCount":1237,"commentCount":0,"publisher":{"@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#organization"},"image":{"@id":"https:\/\/griddb.net\/en\/blog\/crud-operations-on-griddb-with-langchain\/#primaryimage"},"thumbnailUrl":"\/wp-content\/uploads\/2024\/09\/Gemini_Generated_Image_j8dq2uj8dq2uj8dq.jpg","articleSection":["Blog"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/griddb.net\/en\/blog\/crud-operations-on-griddb-with-langchain\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/griddb.net\/en\/blog\/crud-operations-on-griddb-with-langchain\/","url":"https:\/\/griddb.net\/en\/blog\/crud-operations-on-griddb-with-langchain\/","name":"CRUD Operations on GridDB with LangChain | GridDB: Open Source Time Series Database for IoT","isPartOf":{"@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/griddb.net\/en\/blog\/crud-operations-on-griddb-with-langchain\/#primaryimage"},"image":{"@id":"https:\/\/griddb.net\/en\/blog\/crud-operations-on-griddb-with-langchain\/#primaryimage"},"thumbnailUrl":"\/wp-content\/uploads\/2024\/09\/Gemini_Generated_Image_j8dq2uj8dq2uj8dq.jpg","datePublished":"2024-07-26T07:00:00+00:00","dateModified":"2025-11-13T20:57:03+00:00","description":"This article explains how to use natural language queries to perform CRUD (create, read, update, and delete) operations on GridDB. You will use the Python","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/griddb.net\/en\/blog\/crud-operations-on-griddb-with-langchain\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/griddb.net\/en\/blog\/crud-operations-on-griddb-with-langchain\/#primaryimage","url":"\/wp-content\/uploads\/2024\/09\/Gemini_Generated_Image_j8dq2uj8dq2uj8dq.jpg","contentUrl":"\/wp-content\/uploads\/2024\/09\/Gemini_Generated_Image_j8dq2uj8dq2uj8dq.jpg","width":1536,"height":1536},{"@type":"WebSite","@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#website","url":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/","name":"GridDB: Open Source Time Series Database for IoT","description":"GridDB is an open source time-series database with the performance of NoSQL and convenience of SQL","publisher":{"@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#organization","name":"Fixstars","url":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#\/schema\/logo\/image\/","url":"https:\/\/griddb.net\/wp-content\/uploads\/2019\/04\/fixstars_logo_web_tagline.png","contentUrl":"https:\/\/griddb.net\/wp-content\/uploads\/2019\/04\/fixstars_logo_web_tagline.png","width":200,"height":83,"caption":"Fixstars"},"image":{"@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/griddbcommunity\/","https:\/\/x.com\/GridDBCommunity","https:\/\/www.linkedin.com\/company\/griddb-by-toshiba"]},{"@type":"Person","@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#\/schema\/person\/4fe914ca9576878e82f5e8dd3ba52233","name":"griddb-admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/5bceca1cafc06886a7ba873e2f0a28011a1176c4dea59709f735b63ae30d0342?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/5bceca1cafc06886a7ba873e2f0a28011a1176c4dea59709f735b63ae30d0342?s=96&d=mm&r=g","caption":"griddb-admin"},"url":"https:\/\/griddb.net\/en\/author\/griddb-admin\/"}]}},"_links":{"self":[{"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/posts\/46807","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/comments?post=46807"}],"version-history":[{"count":1,"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/posts\/46807\/revisions"}],"predecessor-version":[{"id":51469,"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/posts\/46807\/revisions\/51469"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/media\/30219"}],"wp:attachment":[{"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/media?parent=46807"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/categories?post=46807"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/tags?post=46807"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}