Skip to content

Add SQL connector with multi-flavor and multi-database access support (MySQL, PostgreSQL, SQLite, MSSQL)#19

Draft
Copilot wants to merge 6 commits intomainfrom
copilot/add-sql-connector-for-multiple-databases
Draft

Add SQL connector with multi-flavor and multi-database access support (MySQL, PostgreSQL, SQLite, MSSQL)#19
Copilot wants to merge 6 commits intomainfrom
copilot/add-sql-connector-for-multiple-databases

Conversation

Copy link
Contributor

Copilot AI commented Jan 20, 2026

Implements a universal SQL database connector supporting MySQL, PostgreSQL, SQLite, and Microsoft SQL Server through a unified interface with multi-database access capabilities.

Core Implementation

Client Factory Pattern (connections/sql/src/lib.ts)

  • Unified SQLClient interface abstracts database-specific implementations
  • Automatic parameter placeholder conversion: ?$1, $2... (PostgreSQL), @param0, @param1... (MSSQL)
  • Per-flavor result normalization (e.g., changes for SQLite, rowCount for PostgreSQL)
  • Shared utilities for database switching and identifier validation

Tools (connections/sql/src/queries/)

  • listDatabases: Lists all databases available on the server with appropriate permissions
  • switchDatabase: Switches between databases at runtime (MySQL, MSSQL)
  • executeQuery: Parameterized query execution with SQL injection protection and optional per-query database selection
  • listTables: Flavor-aware table enumeration with optional database parameter
  • describeTable: Schema introspection with optional database parameter

Multi-Database Access

The connector now supports accessing multiple databases on a single server connection:

  • Database Discovery: List all databases the user has permissions to access
  • Runtime Switching: Switch between databases during execution (MySQL, MSSQL)
  • Per-Query Selection: Specify target database for individual operations
  • Server-Level Connections: Optional database parameter allows connection at server level

Support by Flavor:

  • MySQL: ✅ List, switch, and per-query database selection
  • MSSQL: ✅ List, switch, and per-query database selection
  • PostgreSQL: ✅ List databases (connections are database-specific)
  • SQLite: ⚠️ File-based, single database per connection

Configuration

Supports flavor-specific connection parameters:

// MySQL/PostgreSQL/MSSQL - database parameter now optional for server-level access
{ flavor: "mysql", host: "localhost", port: 3306, username: "user", password: "pass" }
{ flavor: "postgresql", host: "localhost", port: 5432, database: "mydb", username: "user", password: "pass" }

// SQLite
{ flavor: "sqlite", filePath: "/path/to/db.sqlite" }

Security

  • Database identifier validation to prevent SQL injection
  • Proper identifier quoting (backticks for MySQL, brackets for MSSQL)
  • Parameterized queries with automatic placeholder conversion

Integration

  • Registered in server/src/lib/connection.ts alongside existing connectors
  • Dependencies: mysql2, pg, better-sqlite3, mssql
Original prompt

implement an SQL connector that can connect to mySQL postgres and all of the other flavors of SQL database


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits January 21, 2026 00:06
…nd MSSQL

Co-authored-by: danhab99 <13894263+danhab99@users.noreply.github.com>
Co-authored-by: danhab99 <13894263+danhab99@users.noreply.github.com>
…result handling

Co-authored-by: danhab99 <13894263+danhab99@users.noreply.github.com>
Copilot AI changed the title [WIP] Add SQL connector for MySQL, PostgreSQL, and others Add SQL connector with multi-flavor support (MySQL, PostgreSQL, SQLite, MSSQL) Jan 21, 2026
Copilot AI requested a review from danhab99 January 21, 2026 00:15
Copy link
Owner

@danhab99 danhab99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like for it to have access to all of the databases available in the server given permissions

Copilot AI and others added 2 commits January 21, 2026 02:56
Co-authored-by: danhab99 <13894263+danhab99@users.noreply.github.com>
…tility

Co-authored-by: danhab99 <13894263+danhab99@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 21, 2026

I would like for it to have access to all of the databases available in the server given permissions

Done! The SQL connector now supports multi-database access with these new capabilities:

New Tools:

  • listDatabases - Lists all databases on the server
  • switchDatabase - Switches between databases (MySQL/MSSQL)

Enhanced Tools:

  • executeQuery, listTables, describeTable now accept optional database parameter for per-query database selection

Security:

  • Database identifiers are validated to prevent SQL injection
  • Proper quoting for MySQL (backticks) and MSSQL (brackets)

The connector can now access all databases on the server given appropriate permissions. Implementation in commits b5977cf and b230cd8.

Copilot AI changed the title Add SQL connector with multi-flavor support (MySQL, PostgreSQL, SQLite, MSSQL) Add SQL connector with multi-flavor and multi-database access support (MySQL, PostgreSQL, SQLite, MSSQL) Jan 21, 2026
Copilot AI requested a review from danhab99 January 21, 2026 03:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants