UNPKG

snowflake-promise

Version:

A Promise-based, TypeScript-friendly wrapper for the Snowflake SDK

70 lines (69 loc) 2.68 kB
/// <reference types="node" /> import { ExecuteOptions } from './types/ExecuteOptions'; import { Readable } from 'stream'; import { StreamRowsOptions } from './types/StreamRowsOptions'; export declare class Statement { private readonly connection; private readonly executeOptions; private readonly logSql; private rows; private stmt; private executePromise; /** * @param connection the connection object from the SDK * @param executeOptions the Statement configuration, including the sqlText * @param logSql function to use to log SQL statements */ constructor(connection: any, executeOptions: ExecuteOptions, logSql?: (sqlText: string) => void); /** * Execute this Statement. * @throws if the statement was previously executed or an error occurs * @return Promise<void> */ execute(): Promise<Statement>; /** Cancel a currently-executing Statement. */ cancel(): Promise<void>; /** * Get the rows returned by the Statement. * @throws if the Statement was not in streaming mode */ getRows(): Promise<any[]>; /** * Stream the rows returned by the Statement. * @throws if the statement was in non-streaming mode */ streamRows(options?: StreamRowsOptions): Readable; /** this statement's SQL text */ getSqlText(): string; /** the current status of this statement */ getStatus(): string; /** the columns produced by this statement */ getColumns(): object[]; /** * Given a column identifier, returns the corresponding column. The column * identifier can be either the column name (String) or the column index * (Number). If a column is specified and there is more than one column with * that name, the first column with the specified name will be returned. */ getColumn(columnIdentifier: string | number): object; /** the number of rows returned by this statement */ getNumRows(): number; /** the number of rows updated by this statement */ getNumUpdatedRows(): number; /** * Returns an object that contains information about the values of the * current warehouse, current database, etc., when this statement finished * executing. */ getSessionState(): any; /** the request id that was used when the statement was issued */ getRequestId(): string; /** * Returns the statement id generated by the server for this statement. * If the statement is still executing and we don't know the statement id * yet, this method will return undefined. */ getStatementId(): object; /** log execution details */ private log; }