Repository navigation
connExt.DataTransfer.Class.DataTransferConnExt
tedious-plus / connExt/DataTransfer / DataTransferConnExt
Defined in: connExt/DataTransfer.ts:26
Data transfer functions for a database connection.
This class is accessed via Connection.transfer.
new DataTransferConnExt(connection): DataTransferConnExt;Defined in: connExt/DataTransfer.ts:33
Creates a DataTransferConnExt object. Applications use Connection.transfer instead.
DataTransferConnExt
exportQuery(sql, options): Promise<number>;Defined in: connExt/DataTransfer.ts:62
Executes an SQL query and exports the rows of the result set into a file or into an entry of a ZIP archive.
The rows are written as they arrive from the server, so large result sets can be exported without buffering them in memory. The output format is JSON Lines (JSONL), with one line per row (see ExportMain.ExportFormatTypeJsonlOptions).
Usage:
await conn.transfer.exportQuery("select * from t1", {output: {type: "file", path: "t1.jsonl"}});
await conn.transfer.exportQuery("select * from t2", {output: {type: "zip", zipPath: "export.zip", entryName: "t2.jsonl", ifExists: "addEntry"}});The Tedious connection option useUTC must not be set to false.
When the export fails, the state of the output file is undefined. It may be incomplete or invalid.
string
The SQL query to be executed.
The output file, optional settings for the columns and the format, request options and SQL parameters.
Promise<number>
A promise for the number of rows exported. The promise is rejected when the query or the export fails.
exportTable(tableName, options): Promise<number>;Defined in: connExt/DataTransfer.ts:91
Exports the rows of a table into a file or into an entry of a ZIP archive.
The rows are exported in the order of the primary key. Unlike with DataTransferConnExt.exportQuery,
the columns are ordered by name and rowversion columns are omitted by default
(options columns.orderByName and columns.omitRowversion). Otherwise, the notes of exportQuery() apply.
Supported are user-defined tables of the current database, tables of another database on the same server,
and temporary tables (see CatalogConnExt.resolveTable()).
Usage:
await conn.transfer.exportTable("dbo.t1", {output: {type: "file", path: "t1.jsonl"}});string
The name of the table, e.g. t1, dbo.t1, [otherDb].[dbo].[t1] or #t1.
The output file, optional settings for the columns and the format, and request options.
Promise<number>
A promise for the number of rows exported. The promise is rejected when the table is not found or the export fails.