Skip to content

Commit

Permalink
fix mysql connection string
Browse files Browse the repository at this point in the history
  • Loading branch information
thrownullexception committed Feb 22, 2024
1 parent dbf800a commit e374caf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{
"name": "@dashpress/bacteria",
"version": "0.0.11",
"version": "0.0.12",
"license": "MIT",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"author": "Ayobami Akingbade",
"module": "dist/bacteria.esm.js",
"files": ["dist"],
"files": [
"dist"
],
"scripts": {
"test": "jest --detectOpenHandles --runInBand",
"start": "tsdx watch",
Expand Down
16 changes: 15 additions & 1 deletion src/utils/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,28 @@ const SupportedDataSourceToKnexClientMap: Record<
const handleStringCredentials = (credentials: string) => {
if (credentials.startsWith("sqlite")) {
return knex({
client: "better-sqlite3",
client: SupportedDataSourceToKnexClientMap[RDMSSources.Sqlite],
connection: {
filename: credentials.split(":")[1],
},
useNullAsDefault: true,
});
}

if (credentials.startsWith("mysql:")) {
return knex({
client: SupportedDataSourceToKnexClientMap[RDMSSources.MySql],
connection: credentials,
});
}

if (credentials.startsWith("mssql:")) {
return knex({
client: SupportedDataSourceToKnexClientMap[RDMSSources.MsSql],
connection: credentials,
});
}

return knex(credentials);
};

Expand Down

0 comments on commit e374caf

Please sign in to comment.