AI SQL Query Generator from Database Schema

9b1b74ad-b0de-4aad-a9ac-b7410bd13154

Latency
6131ms
Cost
$0.0047
Tokens
698
Status
success
gpt-4o-mini

Workflow Graph

Trace

[
  {
    "data": {
      "nodeType": "llm"
    },
    "event": "node_start",
    "nodeId": "b7c3ca47-11b3-4378-81fa-68b2f56b295e",
    "timestamp": 1783210614342
  },
  {
    "data": {
      "messages": 1,
      "maxTokens": 1024
    },
    "event": "calling openai/gpt-4o",
    "nodeId": "llm",
    "timestamp": 1783210614342
  },
  {
    "data": {
      "model": "gpt-4o",
      "provider": "openai"
    },
    "event": "llm_call",
    "nodeId": "_context",
    "timestamp": 1783210614342
  },
  {
    "data": {
      "model": "gpt-4o-mini-2024-07-18",
      "costUsd": 0.0001075,
      "provider": "openai",
      "latencyMs": 864,
      "promptTokens": 7,
      "completionTokens": 9
    },
    "event": "llm_result",
    "nodeId": "_context",
    "timestamp": 1783210615209
  },
  {
    "data": {
      "status": "ok",
      "nodeType": "llm"
    },
    "event": "node_end",
    "nodeId": "b7c3ca47-11b3-4378-81fa-68b2f56b295e",
    "timestamp": 1783210615209
  },
  {
    "data": {
      "nodeType": "passthrough"
    },
    "event": "node_start",
    "nodeId": "977c3a82-440b-4d44-9042-47a673bcb52c",
    "timestamp": 1783210615210
  },
  {
    "data": {},
    "event": "noOp",
    "nodeId": "passthrough",
    "timestamp": 1783210615210
  },
  {
    "data": {
      "status": "ok",
      "nodeType": "passthrough"
    },
    "event": "node_end",
    "nodeId": "977c3a82-440b-4d44-9042-47a673bcb52c",
    "timestamp": 1783210615210
  },
  {
    "data": {
      "nodeType": "trigger"
    },
    "event": "node_start",
    "nodeId": "96f129c0-d1d4-4cbf-a24d-0b0cea18a229",
    "timestamp": 1783210615212
  },
  {
    "data": {
      "kind": "@n8n/n8n-nodes-langchain.chatTrigger"
    },
    "event": "seeded",
    "nodeId": "trigger",
    "timestamp": 1783210615212
  },
  {
    "data": {
      "status": "ok",
      "nodeType": "trigger"
    },
    "event": "node_end",
    "nodeId": "96f129c0-d1d4-4cbf-a24d-0b0cea18a229",
    "timestamp": 1783210615212
  },
  {
    "data": {
      "nodeType": "manualTrigger"
    },
    "event": "node_start",
    "nodeId": "c8ac730a-04ee-499d-b845-1149967d6aa2",
    "timestamp": 1783210615212
  },
  {
    "data": {
      "initialData": {
        "data": null,
        "query": null,
        "action": "generate_sql",
        "output": null,
        "schema": "CREATE TABLE users (\n  user_id INT AUTO_INCREMENT PRIMARY KEY,\n  username VARCHAR(50) NOT NULL UNIQUE,\n  email VARCHAR(100) NOT NULL UNIQUE,\n  registration_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP\n);\n\nCREATE TABLE products (\n  product_id INT AUTO_INCREMENT PRIMARY KEY,\n  product_name VARCHAR(100) NOT NULL,\n  description TEXT,\n  price DECIMAL(10, 2) NOT NULL,\n  stock_quantity INT NOT NULL\n);\n\nCREATE TABLE orders (\n  order_id INT AUTO_INCREMENT PRIMARY KEY,\n  user_id INT,\n  order_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n  total_amount DECIMAL(10, 2),\n  status ENUM('pending', 'processing', 'shipped', 'delivered', 'cancelled') DEFAULT 'pending',\n  FOREIGN KEY (user_id) REFERENCES users(user_id)\n);\n\nCREATE TABLE order_items (\n  order_item_id INT AUTO_INCREMENT PRIMARY KEY,\n  order_id INT,\n  product_id INT,\n  quantity INT NOT NULL,\n  price_at_order DECIMAL(10, 2) NOT NULL,\n  FOREIGN KEY (order_id) REFERENCES orders(order_id),\n  FOREIGN KEY (product_id) REFERENCES products(product_id)\n);",
        "chatInput": "Show me all users who registered in the last month and their total order amounts.",
        "sessionId": "session_12345",
        "sqloutput": null,
        "output.match": null,
        "Tables_in_tttytdb2023": [
          "users",
          "products",
          "orders",
          "order_items"
        ]
      }
    },
    "event": "triggered",
    "nodeId": "manualTrigger",
    "timestamp": 1783210615212
  },
  {
    "data": {
      "status": "ok",
      "nodeType": "manualTrigger"
    },
    "event": "node_end",
    "nodeId": "c8ac730a-04ee-499d-b845-1149967d6aa2",
    "timestamp": 1783210615212
  },
  {
    "data": {
      "nodeType": "passthrough"
    },
    "event": "node_start",
    "nodeId": "e4045e33-bb87-488d-8ccf-b4a94339a841",
    "timestamp": 1783210615213
  },
  {
    "data": {},
    "event": "noOp",
    "nodeId": "passthrough",
    "timestamp": 1783210615213
  },
  {
    "data": {
      "status": "ok",
      "nodeType": "passthrough"
    },
    "event": "node_end",
    "nodeId": "e4045e33-bb87-488d-8ccf-b4a94339a841",
    "timestamp": 1783210615213
  },
  {
    "data": {
      "nodeType": "integration"
    },
    "event": "node_start",
    "nodeId": "4c141ae8-d2d1-45c7-bb5d-f33841d3cee6",
    "timestamp": 1783210615214
  },
  {
    "data": {
      "mode": "write",
      "status": "ok",
      "service": "mysql",
      "safeMode": true,
      "latencyMs": 180,
      "operation": "executeQuery",
      "simulated": true
    },
    "event": "integration_mocked",
    "nodeId": "integration",
    "timestamp": 1783210615396
  },
  {
    "data": {
      "status": "ok",
      "nodeType": "integration"
    },
    "event": "node_end",
    "nodeId": "4c141ae8-d2d1-45c7-bb5d-f33841d3cee6",
    "timestamp": 1783210615396
  },
  {
    "data": {
      "nodeType": "passthrough"
    },
    "event": "node_start",
    "nodeId": "04511c4f-44fa-4c23-87af-54d959e6cb2c",
    "timestamp": 1783210615397
  },
  {
    "data": {},
    "event": "noOp",
    "nodeId": "passthrough",
    "timestamp": 1783210615397
  },
  {
    "data": {
      "status": "ok",
      "nodeType": "passthrough"
    },
    "event": "node_end",
    "nodeId": "04511c4f-44fa-4c23-87af-54d959e6cb2c",
    "timestamp": 1783210615397
  },
  {
    "data": {
      "nodeType": "integration"
    },
    "event": "node_start",
    "nodeId": "54fb3362-041b-4e4f-bfea-f0bc788d8dfd",
    "timestamp": 1783210615399
  },
  {
    "data": {
      "mode": "write",
      "status": "ok",
      "service": "mysql",
      "safeMode": true,
      "latencyMs": 180,
      "operation": "executeQuery",
      "simulated": true
    },
    "event": "integration_mocked",
    "nodeId": "integration",
    "timestamp": 1783210615580
  },
  {
    "data": {
      "status": "ok",
      "nodeType": "integration"
    },
    "event": "node_end",
    "nodeId": "54fb3362-041b-4e4f-bfea-f0bc788d8dfd",
    "timestamp": 1783210615580
  },
  {
    "data": {
      "nodeType": "set"
    },
    "event": "node_start",
    "nodeId": "0cd425db-2a8e-4f48-b749-9a082e948395",
    "timestamp": 1783210615581
  },
  {
    "data": {
      "inputKeys": [
        "Tables_in_tttytdb2023",
        "schema",
        "chatInput",
        "sessionId",
        "action",
        "data",
        "output.match",
        "query",
        "output",
        "sqloutput"
      ],
      "mergeKeys": []
    },
    "event": "merged",
    "nodeId": "set",
    "timestamp": 1783210615581
  },
  {
    "data": {
      "status": "ok",
      "nodeType": "set"
    },
    "event": "node_end",
    "nodeId": "0cd425db-2a8e-4f48-b749-9a082e948395",
    "timestamp": 1783210615581
  },
  {
    "data": {
      "nodeType": "set"
    },
    "event": "node_start",
    "nodeId": "d55e841d-11ed-4ce2-8c8e-840bd807ff2c",
    "timestamp": 1783210615583
  },
  {
    "data": {
      "inputKeys": [
        "ok",
        "id",
        "simulated",
        "echo"
      ],
      "mergeKeys": []
    },
    "event": "merged",
    "nodeId": "set",
    "timestamp": 1783210615583
  },
  {
    "data": {
      "status": "ok",
      "nodeType": "set"
    },
    "event": "node_end",
    "nodeId": "d55e841d-11ed-4ce2-8c8e-840bd807ff2c",
    "timestamp": 1783210615583
  },
  {
    "data": {
      "nodeType": "llm"
    },
    "event": "node_start",
    "nodeId": "4d993ed9-3bbe-4bc3-9e5b-c3d738b0e714",
    "timestamp": 1783210615584
  },
  {
    "data": {
      "messages": 2,
      "maxTokens": 1024
    },
    "event": "calling openai/gpt-4o-mini",
    "nodeId": "llm",
    "timestamp": 1783210615584
  },
  {
    "data": {
      "model": "gpt-4o-mini",
      "provider": "openai"
    },
    "event": "llm_call",
    "nodeId": "_context",
    "timestamp": 1783210615584
  },
  {
    "data": {
      "model": "gpt-4o-mini-2024-07-18",
      "costUsd": 0.0045775,
      "provider": "openai",
      "latencyMs": 4698,
      "promptTokens": 299,
      "completionTokens": 383
    },
    "event": "llm_result",
    "nodeId": "_context",
    "timestamp": 1783210620282
  },
  {
    "data": {
      "status": "ok",
      "nodeType": "llm"
    },
    "event": "node_end",
    "nodeId": "4d993ed9-3bbe-4bc3-9e5b-c3d738b0e714",
    "timestamp": 1783210620282
  },
  {
    "data": {
      "nodeType": "passthrough"
    },
    "event": "node_start",
    "nodeId": "ca8d30d6-c1f1-4e89-8cd5-ea3648dc3b0c",
    "timestamp": 1783210620284
  },
  {
    "data": {},
    "event": "noOp",
    "nodeId": "passthrough",
    "timestamp": 1783210620284
  },
  {
    "data": {
      "status": "ok",
      "nodeType": "passthrough"
    },
    "event": "node_end",
    "nodeId": "ca8d30d6-c1f1-4e89-8cd5-ea3648dc3b0c",
    "timestamp": 1783210620284
  },
  {
    "data": {
      "nodeType": "set"
    },
    "event": "node_start",
    "nodeId": "367ebe95-0b87-44f6-8392-33fe65446c24",
    "timestamp": 1783210620285
  },
  {
    "data": {
      "inputKeys": [
        "text",
        "model",
        "usage"
      ],
      "mergeKeys": []
    },
    "event": "merged",
    "nodeId": "set",
    "timestamp": 1783210620285
  },
  {
    "data": {
      "status": "ok",
      "nodeType": "set"
    },
    "event": "node_end",
    "nodeId": "367ebe95-0b87-44f6-8392-33fe65446c24",
    "timestamp": 1783210620285
  },
  {
    "data": {
      "nodeType": "passthrough"
    },
    "event": "node_start",
    "nodeId": "2d89f901-d4e7-4fea-bd69-20b518280bbc",
    "timestamp": 1783210620286
  },
  {
    "data": {},
    "event": "noOp",
    "nodeId": "passthrough",
    "timestamp": 1783210620286
  },
  {
    "data": {
      "status": "ok",
      "nodeType": "passthrough"
    },
    "event": "node_end",
    "nodeId": "2d89f901-d4e7-4fea-bd69-20b518280bbc",
    "timestamp": 1783210620286
  },
  {
    "data": {
      "nodeType": "if"
    },
    "event": "node_start",
    "nodeId": "b856fe78-2435-4075-97f8-ecbeecf3e780",
    "timestamp": 1783210620287
  },
  {
    "event": "true branch",
    "nodeId": "if",
    "timestamp": 1783210620287
  },
  {
    "data": {
      "status": "ok",
      "nodeType": "if"
    },
    "event": "node_end",
    "nodeId": "b856fe78-2435-4075-97f8-ecbeecf3e780",
    "timestamp": 1783210620287
  },
  {
    "data": {
      "nodeType": "integration"
    },
    "event": "node_start",
    "nodeId": "d958de24-84ef-4928-a7f3-32cada09a0eb",
    "timestamp": 1783210620289
  },
  {
    "data": {
      "mode": "write",
      "status": "ok",
      "service": "mysql",
      "safeMode": true,
      "latencyMs": 180,
      "operation": "executeQuery",
      "simulated": true
    },
    "event": "integration_mocked",
    "nodeId": "integration",
    "timestamp": 1783210620469
  },
  {
    "data": {
      "status": "ok",
      "nodeType": "integration"
    },
    "event": "node_end",
    "nodeId": "d958de24-84ef-4928-a7f3-32cada09a0eb",
    "timestamp": 1783210620469
  },
  {
    "data": {
      "nodeType": "passthrough"
    },
    "event": "node_start",
    "nodeId": "c6e9c0e2-d238-4f0b-a4c8-2271f2c8b31b",
    "timestamp": 1783210620470
  },
  {
    "data": {},
    "event": "noOp",
    "nodeId": "passthrough",
    "timestamp": 1783210620470
  },
  {
    "data": {
      "status": "ok",
      "nodeType": "passthrough"
    },
    "event": "node_end",
    "nodeId": "c6e9c0e2-d238-4f0b-a4c8-2271f2c8b31b",
    "timestamp": 1783210620470
  },
  {
    "data": {
      "nodeType": "set"
    },
    "event": "node_start",
    "nodeId": "cbb6d1e1-0a75-4b3a-89cd-6bd545b8d414",
    "timestamp": 1783210620471
  },
  {
    "data": {
      "inputKeys": [
        "ok",
        "id",
        "simulated",
        "echo"
      ],
      "mergeKeys": []
    },
    "event": "merged",
    "nodeId": "set",
    "timestamp": 1783210620471
  },
  {
    "data": {
      "status": "ok",
      "nodeType": "set"
    },
    "event": "node_end",
    "nodeId": "cbb6d1e1-0a75-4b3a-89cd-6bd545b8d414",
    "timestamp": 1783210620471
  },
  {
    "data": {
      "nodeType": "merge"
    },
    "event": "node_start",
    "nodeId": "9380c2f6-15d9-43e4-80a2-3019bcf5ae04",
    "timestamp": 1783210620472
  },
  {
    "data": {
      "inputCount": 2
    },
    "event": "merged 2 inputs",
    "nodeId": "merge",
    "timestamp": 1783210620472
  },
  {
    "data": {
      "status": "ok",
      "nodeType": "merge"
    },
    "event": "node_end",
    "nodeId": "9380c2f6-15d9-43e4-80a2-3019bcf5ae04",
    "timestamp": 1783210620472
  },
  {
    "data": {
      "nodeType": "set"
    },
    "event": "node_start",
    "nodeId": "99a6dc03-1035-4866-81e4-11dc66bf98ec",
    "timestamp": 1783210620473
  },
  {
    "data": {
      "inputKeys": [
        "ok",
        "id",
        "simulated",
        "echo",
        "text",
        "model",
        "usage"
      ],
      "mergeKeys": []
    },
    "event": "merged",
    "nodeId": "set",
    "timestamp": 1783210620473
  },
  {
    "data": {
      "status": "ok",
      "nodeType": "set"
    },
    "event": "node_end",
    "nodeId": "99a6dc03-1035-4866-81e4-11dc66bf98ec",
    "timestamp": 1783210620473
  }
]