mssql bulk table writer

This commit is contained in:
Jan Prochazka
2020-06-11 13:58:34 +02:00
parent a86f7e96ca
commit 38b6350ef8
12 changed files with 187 additions and 4 deletions

View File

@@ -4,4 +4,5 @@ export interface SqlDialect {
stringEscapeChar: string;
offsetFetchRangeSyntax?: boolean;
quoteIdentifier(s: string): string;
fallbackDataType?: string;
}

View File

@@ -2,7 +2,7 @@ import stream from 'stream';
import { QueryResult } from './query';
import { SqlDialect } from './dialect';
import { SqlDumper } from './dumper';
import { DatabaseInfo, NamedObjectInfo } from './dbinfo';
import { DatabaseInfo, NamedObjectInfo, TableInfo, ViewInfo, ProcedureInfo, FunctionInfo, TriggerInfo } from './dbinfo';
export interface StreamOptions {
recordset: (columns) => void;
@@ -12,13 +12,25 @@ export interface StreamOptions {
info: (info) => void;
}
export interface WriteTableOptions {
dropIfExists?: boolean;
truncate?: boolean;
createIfNotExists?: boolean;
}
export interface EngineDriver {
engine: string;
connect(nativeModules, { server, port, user, password, database }): any;
query(pool: any, sql: string): Promise<QueryResult>;
stream(pool: any, sql: string, options: StreamOptions);
readQuery(pool: any, sql: string): Promise<stream.Readable>;
writeTable(pool: any, { schemaName, pureName }): Promise<stream.Writeable>;
writeTable(pool: any, name: NamedObjectInfo, options: WriteTableOptions): Promise<stream.Writeable>;
analyseSingleObject(
pool: any,
name: NamedObjectInfo,
objectTypeField: keyof DatabaseInfo
): Promise<TableInfo | ViewInfo | ProcedureInfo | FunctionInfo | TriggerInfo>;
analyseSingleTable(pool: any, name: NamedObjectInfo): Promise<TableInfo>;
getVersion(pool: any): Promise<{ version: string }>;
listDatabases(
pool: any