在准备环境前提交次全部更改。
This commit is contained in:
42
apps/backend/app/schemas/db_viewer.py
Normal file
42
apps/backend/app/schemas/db_viewer.py
Normal file
@@ -0,0 +1,42 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""数据库查看器 Pydantic 模型
|
||||
|
||||
定义 Schema 浏览、表结构查看、SQL 查询的请求/响应模型。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class SchemaInfo(BaseModel):
|
||||
"""Schema 信息。"""
|
||||
name: str
|
||||
|
||||
|
||||
class TableInfo(BaseModel):
|
||||
"""表信息(含行数统计)。"""
|
||||
name: str
|
||||
row_count: int | None = None
|
||||
|
||||
|
||||
class ColumnInfo(BaseModel):
|
||||
"""列定义。"""
|
||||
name: str
|
||||
data_type: str
|
||||
is_nullable: bool
|
||||
column_default: str | None = None
|
||||
|
||||
|
||||
class QueryRequest(BaseModel):
|
||||
"""SQL 查询请求。"""
|
||||
sql: str
|
||||
|
||||
|
||||
class QueryResponse(BaseModel):
|
||||
"""SQL 查询响应。"""
|
||||
columns: list[str]
|
||||
rows: list[list[Any]]
|
||||
row_count: int
|
||||
Reference in New Issue
Block a user