MCPcopy Create free account
hub / github.com/Houseofmvps/codesight / extractSQLModelAST

Function extractSQLModelAST

src/ast/extract-python.ts:670–688  ·  view source on GitHub ↗
(
  filePath: string,
  content: string
)

Source from the content-addressed store, hash-verified

668 })) as SchemaField[],
669 relations: (m.relations || []).map((r: any) =>
670 `${r.name}: ${r.type === "many" ? "many" : "one"}(${r.target})`
671 ),
672 orm: "django" as const,
673 confidence: "ast" as const,
674 }));
675}
676
677/**
678 * Extract SQLModel table models from a Python file using AST.
679 * Detects class X(SQLModel, table=True) with typed field annotations.
680 */
681export async function extractSQLModelAST(
682 filePath: string,
683 content: string
684): Promise<SchemaModel[] | null> {
685 const result = await runPythonWithStdin(PYTHON_SQLMODEL_SCRIPT, content, filePath);
686 if (!result || !Array.isArray(result) || result.length === 0) return null;
687
688 return result.map((m: any) => ({
689 name: m.name,
690 fields: (m.fields || []).map((f: any) => ({
691 name: f.name,

Callers 1

detectSQLAlchemySchemasFunction · 0.85

Calls 1

runPythonWithStdinFunction · 0.85

Tested by

no test coverage detected