Skip to content

Commit da56215

Browse files
authored
Merge pull request #18 from Thomas-Matheus/mariadb-support
Add Maria DB Connector
2 parents 1e0f0d9 + 20893db commit da56215

File tree

8 files changed

+494
-8
lines changed

8 files changed

+494
-8
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ https://demo.dbhub.ai/sse connects a [sample employee database](https://github.c
4949

5050
| Tool | Command Name | PostgreSQL | MySQL | SQL Server | SQLite |
5151
| --------------- | ----------------- | :--------: | :---: | :--------: | :----: |
52-
| Execute Query | `run_query` |||||
53-
| List Connectors | `list_connectors` |||||
52+
| Execute Query | `run_query` ||||||
53+
| List Connectors | `list_connectors` ||||||
5454

5555
### Prompt Capabilities
5656

5757
| Prompt | Command Name | PostgreSQL | MySQL | SQL Server | SQLite |
5858
| ------------------- | -------------- | :--------: | :---: | :--------: | :----: |
59-
| Generate SQL | `generate_sql` |||||
60-
| Explain DB Elements | `explain_db` |||||
59+
| Generate SQL | `generate_sql` ||||||
60+
| Explain DB Elements | `explain_db` ||||||
6161

6262
## Installation
6363

@@ -192,6 +192,7 @@ DBHub supports the following database connection string formats:
192192
| SQLite | `sqlite:///[path/to/file]` or `sqlite::memory:` | `sqlite:///path/to/database.db` or `sqlite::memory:` |
193193
| SQL Server | `sqlserver://[user]:[password]@[host]:[port]/[database]` | `sqlserver://user:password@localhost:1433/dbname` |
194194
| MySQL | `mysql://[user]:[password]@[host]:[port]/[database]` | `mysql://user:password@localhost:3306/dbname` |
195+
| MariaDB | `mariadb://[user]:[password]@[host]:[port]/[database]` | `mariadb://user:password@localhost:3306/dbname` |
195196

196197
### Transport
197198

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"dotenv": "^16.4.7",
2828
"express": "^4.18.2",
2929
"mssql": "^11.0.1",
30+
"mariadb": "^3.4.0",
3031
"mysql2": "^3.13.0",
3132
"pg": "^8.13.3",
3233
"zod": "^3.24.2"

src/config/env.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,4 +166,28 @@ export function resolvePort(): { port: number; source: string } {
166166

167167
// 3. Default to 8080
168168
return { port: 8080, source: 'default' };
169-
}
169+
}
170+
171+
/**
172+
* Redact sensitive information from a DSN string
173+
* Replaces the password with asterisks
174+
* @param dsn - The DSN string to redact
175+
* @returns The sanitized DSN string
176+
*/
177+
export function redactDSN(dsn: string): string {
178+
try {
179+
// Create a URL object to parse the DSN
180+
const url = new URL(dsn);
181+
182+
// Replace the password with asterisks
183+
if (url.password) {
184+
url.password = '*******';
185+
}
186+
187+
// Return the sanitized DSN
188+
return url.toString();
189+
} catch (error) {
190+
// If parsing fails, do basic redaction with regex
191+
return dsn.replace(/\/\/([^:]+):([^@]+)@/, '//$1:***@');
192+
}
193+
}

src/connectors/interface.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export interface DSNParser {
3939
* Parse a connection string into connector-specific configuration
4040
* Example DSN formats:
4141
* - PostgreSQL: "postgres://user:password@localhost:5432/dbname?sslmode=disable"
42+
* - MariaDB: "mariadb://user:password@localhost:3306/dbname"
4243
* - MySQL: "mysql://user:password@localhost:3306/dbname"
4344
* - SQLite: "sqlite:///path/to/database.db" or "sqlite::memory:"
4445
*/

0 commit comments

Comments
 (0)