Database SQL builder

Database SQL builder · GPT-Aktionen

Database Actions API

API for retrieving database information.

  • GET /get-all-available-table-namesGetAllAvailableTableNames

    Retrieve a list of available table names

  • POST /get-entity-relationsGetEntityRelations

    Retrieve entity relations for a specified table name

  • POST /get-table-schemaGetTableSchema

    Retrieve the schema of a specified table

Ursprüngliches API-Schema
{
  "openapi": "3.1.0",
  "info": {
    "title": "Database Actions API",
    "description": "API for retrieving database information.",
    "version": "v1.0.0"
  },
  "servers": [
    {
      "url": "https://www.db-gpts.com"
    }
  ],
  "paths": {
    "/get-all-available-table-names": {
      "get": {
        "description": "Retrieve a list of available table names",
        "operationId": "GetAllAvailableTableNames",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "tableNames": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                },
                "example": {
                  "tableNames": [
                    "convictional_seller_order_item",
                    "contract",
                    "buyer_popup",
                    "popup",
                    "mikro_orm_migrations",
                    "test_search_product",
                    "refund_transaction",
                    "stripe_connect",
                    "cart_line_item",
                    "product_wrapper_variant",
                    "checkout_line_item",
                    "product_listing_products",
                    "social_media",
                    "recommend",
                    "bank_info",
                    "special_referral",
                    "recommend_brands",
                    "recommend_product_listings",
                    "product_category",
                    "upcoming",
                    "inventory_item",
                    "task_group_order_record",
                    "task_order_record",
                    "campaign",
                    "referral",
                    "campaign_referral",
                    "referral_sign_buyer",
                    "search_history",
                    "cart",
                    "checkout",
                    "wallet",
                    "withdraw_request",
                    "product_click_event",
                    "wallet_transaction",
                    "buyer_category_preferences",
                    "product_cart_event",
                    "product_listing",
                    "product_wrapper",
                    "order_create_event",
                    "product_item",
                    "buyer_group",
                    "address",
                    "user",
                    "brand_review",
                    "discount",
                    "header_cms",
                    "supplier_sustainability_metric",
                    "category_sustainability_metric",
                    "admin_config",
                    "order_line_item",
                    "order",
                    "payment_transaction",
                    "buyer_notification",
                    "notification",
                    "product_collection",
                    "product",
                    "variant",
                    "sustainability_saving",
                    "supplier",
                    "group_order",
                    "payment",
                    "payment_refund",
                    "supplier_brand",
                    "buyer"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error"
          }
        }
      }
    },
    "/get-entity-relations": {
      "post": {
        "description": "Retrieve entity relations for a specified table name",
        "operationId": "GetEntityRelations",
        "requestBody": {
          "description": "Table name for which entity relations are requested",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "tableNames": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              },
              "example": {
                "tableName": "product"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "relations": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "constraint_name": {
                            "type": "string"
                          },
                          "table_name": {
                            "type": "string"
                          },
                          "column_name": {
                            "type": "string"
                          },
                          "referenced_table_name": {
                            "type": "string"
                          },
                          "referenced_column_name": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                },
                "example": {
                  "relations": [
                    {
                      "constraint_name": "group_order_payment_id_foreign",
                      "table_name": "group_order",
                      "column_name": "payment_id",
                      "referenced_table_name": "payment",
                      "referenced_column_name": "id"
                    },
                    {
                      "constraint_name": "group_order_checkout_id_foreign",
                      "table_name": "group_order",
                      "column_name": "checkout_id",
                      "referenced_table_name": "checkout",
                      "referenced_column_name": "id"
                    },
                    {
                      "constraint_name": "group_order_buyer_id_foreign",
                      "table_name": "group_order",
                      "column_name": "buyer_id",
                      "referenced_table_name": "buyer",
                      "referenced_column_name": "id"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "500": {
            "description": "Internal Server Error"
          }
        }
      }
    },
    "/get-table-schema": {
      "post": {
        "description": "Retrieve the schema of a specified table",
        "operationId": "GetTableSchema",
        "requestBody": {
          "description": "Table name for which the schema is requested",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "tableNames": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              },
              "example": {
                "tableName": "example_table"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "column_name": {
                        "type": "string"
                      },
                      "data_type": {
                        "type": "string"
                      },
                      "is_nullable": {
                        "type": "string"
                      }
                    }
                  }
                },
                "example": [
                  {
                    "column_name": "id",
                    "data_type": "integer",
                    "is_nullable": "NO"
                  },
                  {
                    "column_name": "created_at",
                    "data_type": "timestamp with time zone",
                    "is_nullable": "NO"
                  },
                  {
                    "column_name": "updated_at",
                    "data_type": "timestamp with time zone",
                    "is_nullable": "NO"
                  },
                  {
                    "column_name": "order_modification_threshold",
                    "data_type": "integer",
                    "is_nullable": "NO"
                  },
                  {
                    "column_name": "order_modification_credit_minimum_order_amount",
                    "data_type": "integer",
                    "is_nullable": "NO"
                  },
                  {
                    "column_name": "base_shipping_rate",
                    "data_type": "integer",
                    "is_nullable": "NO"
                  },
                  {
                    "column_name": "variable_shipping_rate",
                    "data_type": "integer",
                    "is_nullable": "NO"
                  },
                  {
                    "column_name": "shipping_unit_threshold",
                    "data_type": "integer",
                    "is_nullable": "NO"
                  },
                  {
                    "column_name": "free_shipping_threshold",
                    "data_type": "integer",
                    "is_nullable": "YES"
                  }
                ]
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "500": {
            "description": "Internal Server Error"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {},
    "securitySchemes": {
      "OAuth2": {
        "type": "oauth2",
        "flows": {
          "authorizationCode": {
            "authorizationUrl": "https://clerk.jczhang.com/oauth/authorize",
            "tokenUrl": "https://clerk.jczhang.com/oauth/token",
            "scopes": {
              "email": "Read user email"
            }
          }
        }
      }
    }
  },
  "security": [
    {
      "OAuth2": [
        "email"
      ]
    }
  ]
}