Skip to content

connExt.DataTransfer.Class.DataTransferConnExt

Christian d'Heureuse edited this page Nov 27, 2026 · 1 revision

tedious-plus / connExt/DataTransfer / DataTransferConnExt

Class: DataTransferConnExt

Defined in: connExt/DataTransfer.ts:26

Data transfer functions for a database connection.

This class is accessed via Connection.transfer.

Constructors

Constructor

new DataTransferConnExt(connection): DataTransferConnExt;

Defined in: connExt/DataTransfer.ts:33

Creates a DataTransferConnExt object. Applications use Connection.transfer instead.

Parameters

connection

Connection

Returns

DataTransferConnExt

Methods

exportQuery()

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.

Parameters

sql

string

The SQL query to be executed.

options

ExportQueryOptions

The output file, optional settings for the columns and the format, request options and SQL parameters.

Returns

Promise<number>

A promise for the number of rows exported. The promise is rejected when the query or the export fails.


exportTable()

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"}});

Parameters

tableName

string

The name of the table, e.g. t1, dbo.t1, [otherDb].[dbo].[t1] or #t1.

options

ExportTableOptions

The output file, optional settings for the columns and the format, and request options.

Returns

Promise<number>

A promise for the number of rows exported. The promise is rejected when the table is not found or the export fails.

Clone this wiki locally