import { Connection, Engine, ExecutionResult, Schema } from "@/types"; import mysql from "./mysql"; import postgres from "./postgres"; import mssql from "./mssql"; export interface Connector { testConnection: () => Promise; execute: (databaseName: string, statement: string) => Promise; getDatabases: () => Promise; getTableSchema: (databaseName: string) => Promise; } export const newConnector = (connection: Connection): Connector => { switch (connection.engineType) { case Engine.MySQL: return mysql(connection); case Engine.PostgreSQL: return postgres(connection); case Engine.MSSQL: return mssql(connection); case Engine.OceanBase: return mysql(connection); default: throw new Error("Unsupported engine type."); } };