@quillsql/node 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/db/DatabaseHelper.d.ts +1 -0
- package/dist/db/DatabaseHelper.js +12 -1
- package/dist/index.js +2 -0
- package/package.json +1 -1
- package/src/db/DatabaseHelper.ts +12 -0
- package/src/index.ts +4 -0
|
@@ -19,6 +19,7 @@ export interface QuillQueryResults {
|
|
|
19
19
|
export declare function getDatabaseCredentials(databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql", connectionString: string): PostgresConnectionConfig | SnowflakeConnectionConfig | BigQueryConfig | MysqlConnectionConfig;
|
|
20
20
|
export declare function connectToDatabase(databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql", config: PostgresConnectionConfig | SnowflakeConnectionConfig | BigQueryConfig | MysqlConnectionConfig): DatabaseConnection;
|
|
21
21
|
export declare function withConnection<T>(databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql", connectionString: string, callback: (connection: DatabaseConnection) => T): Promise<T>;
|
|
22
|
+
export declare function withPool<T>(databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql", pool: DatabaseConnection, callback: (connection: DatabaseConnection) => T): Promise<T>;
|
|
22
23
|
export declare function runQueryByDatabase(databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql", connection: DatabaseConnection, sql: string): Promise<QuillQueryResults> | undefined;
|
|
23
24
|
export declare function connectAndRunQuery(databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql", connectionString: string, sql: string): Promise<QuillQueryResults | undefined>;
|
|
24
25
|
export declare function disconnectFromDatabase(databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql", database: DatabaseConnection): void | Promise<void>;
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.getColumnInfoBySchemaByDatabase = exports.getForiegnKeysByDatabase = exports.getColumnsByTableByDatabase = exports.getTablesBySchemaByDatabase = exports.getSchemasByDatabase = exports.disconnectFromDatabase = exports.connectAndRunQuery = exports.runQueryByDatabase = exports.withConnection = exports.connectToDatabase = exports.getDatabaseCredentials = void 0;
|
|
12
|
+
exports.getColumnInfoBySchemaByDatabase = exports.getForiegnKeysByDatabase = exports.getColumnsByTableByDatabase = exports.getTablesBySchemaByDatabase = exports.getSchemasByDatabase = exports.disconnectFromDatabase = exports.connectAndRunQuery = exports.runQueryByDatabase = exports.withPool = exports.withConnection = exports.connectToDatabase = exports.getDatabaseCredentials = void 0;
|
|
13
13
|
const Postgres_1 = require("./Postgres");
|
|
14
14
|
const Snowflake_1 = require("./Snowflake");
|
|
15
15
|
const BigQuery_1 = require("./BigQuery");
|
|
@@ -61,6 +61,17 @@ function withConnection(databaseType, connectionString, callback) {
|
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
63
|
exports.withConnection = withConnection;
|
|
64
|
+
function withPool(databaseType, pool, callback) {
|
|
65
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
try {
|
|
67
|
+
return yield callback(pool);
|
|
68
|
+
}
|
|
69
|
+
finally {
|
|
70
|
+
yield disconnectFromDatabase(databaseType, pool);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
exports.withPool = withPool;
|
|
64
75
|
function runQueryByDatabase(databaseType, connection, sql) {
|
|
65
76
|
switch (databaseType.toLowerCase()) {
|
|
66
77
|
case "postgres":
|
package/dist/index.js
CHANGED
|
@@ -245,6 +245,8 @@ const requireQuill = ({ privateKey, databaseConnectionString, databaseConfig, ca
|
|
|
245
245
|
module.exports = requireQuill;
|
|
246
246
|
module.exports.default = requireQuill;
|
|
247
247
|
module.exports.withConnection = DatabaseHelper_1.withConnection;
|
|
248
|
+
module.exports.withPool = DatabaseHelper_1.withPool;
|
|
249
|
+
module.exports.connectToDatabase = DatabaseHelper_1.connectToDatabase;
|
|
248
250
|
module.exports.connectAndRunQuery = DatabaseHelper_1.connectAndRunQuery;
|
|
249
251
|
module.exports.Quill = Quill;
|
|
250
252
|
module.exports.getTablesBySchemaByDatabase = DatabaseHelper_1.getTablesBySchemaByDatabase;
|
package/package.json
CHANGED
package/src/db/DatabaseHelper.ts
CHANGED
|
@@ -124,6 +124,18 @@ export async function withConnection<T>(
|
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
+
export async function withPool<T>(
|
|
128
|
+
databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql",
|
|
129
|
+
pool: DatabaseConnection,
|
|
130
|
+
callback: (connection: DatabaseConnection) => T,
|
|
131
|
+
): Promise<T> {
|
|
132
|
+
try {
|
|
133
|
+
return await callback(pool);
|
|
134
|
+
} finally {
|
|
135
|
+
await disconnectFromDatabase(databaseType, pool);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
127
139
|
export function runQueryByDatabase(
|
|
128
140
|
databaseType: "postgresql" | "snowflake" | "bigquery" | "mysql",
|
|
129
141
|
connection: DatabaseConnection,
|
package/src/index.ts
CHANGED
|
@@ -9,6 +9,7 @@ import axios from "axios";
|
|
|
9
9
|
import "dotenv/config";
|
|
10
10
|
import { mapQueries, removeFields } from "./utils/RunQueryProcesses";
|
|
11
11
|
import {
|
|
12
|
+
connectToDatabase,
|
|
12
13
|
connectAndRunQuery,
|
|
13
14
|
getColumnInfoBySchemaByDatabase,
|
|
14
15
|
getColumnsByTableByDatabase,
|
|
@@ -18,6 +19,7 @@ import {
|
|
|
18
19
|
getTablesBySchemaByDatabase,
|
|
19
20
|
runQueryByDatabase,
|
|
20
21
|
withConnection,
|
|
22
|
+
withPool,
|
|
21
23
|
} from "./db/DatabaseHelper";
|
|
22
24
|
import { convertTypeToPostgres } from "./utils/schemaConversion";
|
|
23
25
|
|
|
@@ -360,6 +362,8 @@ const requireQuill = ({
|
|
|
360
362
|
module.exports = requireQuill;
|
|
361
363
|
module.exports.default = requireQuill;
|
|
362
364
|
module.exports.withConnection = withConnection;
|
|
365
|
+
module.exports.withPool = withPool;
|
|
366
|
+
module.exports.connectToDatabase = connectToDatabase;
|
|
363
367
|
module.exports.connectAndRunQuery = connectAndRunQuery;
|
|
364
368
|
module.exports.Quill = Quill;
|
|
365
369
|
module.exports.getTablesBySchemaByDatabase = getTablesBySchemaByDatabase;
|