mirror of
https://github.com/Kaelio/ktx.git
synced 2026-06-25 08:48:08 +02:00
Initial open-source release
This commit is contained in:
commit
1a42152e6f
1199 changed files with 257054 additions and 0 deletions
37
packages/connector-postgres/src/historic-sql-query-client.ts
Normal file
37
packages/connector-postgres/src/historic-sql-query-client.ts
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import type { KloPostgresQueryClient } from '@klo/context/ingest';
|
||||
import { KloPostgresScanConnector, type KloPostgresScanConnectorOptions } from './connector.js';
|
||||
|
||||
export type KloPostgresHistoricSqlQueryClientOptions = KloPostgresScanConnectorOptions;
|
||||
|
||||
export class KloPostgresHistoricSqlQueryClient implements KloPostgresQueryClient {
|
||||
private readonly connectionId: string;
|
||||
private readonly connector: KloPostgresScanConnector;
|
||||
|
||||
constructor(options: KloPostgresHistoricSqlQueryClientOptions) {
|
||||
this.connectionId = options.connectionId;
|
||||
this.connector = new KloPostgresScanConnector(options);
|
||||
}
|
||||
|
||||
async executeQuery(
|
||||
sql: string,
|
||||
params?: unknown[],
|
||||
): Promise<{ headers: string[]; rows: unknown[][]; totalRows: number }> {
|
||||
const result = await this.connector.executeReadOnly(
|
||||
{
|
||||
connectionId: this.connectionId,
|
||||
sql,
|
||||
params,
|
||||
},
|
||||
{} as never,
|
||||
);
|
||||
return {
|
||||
headers: result.headers,
|
||||
rows: result.rows,
|
||||
totalRows: result.totalRows,
|
||||
};
|
||||
}
|
||||
|
||||
async cleanup(): Promise<void> {
|
||||
await this.connector.cleanup();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue