pub struct Connection { /* private fields */ }Expand description
ADBC Connection to an Exasol database.
The Connection type represents an active database connection and provides
methods for executing queries, managing transactions, and retrieving metadata.
§v2.0.0 Breaking Changes
- Connection now owns the transport directly
create_statement()is now synchronous and returns a pure data container- Use
execute_statement()instead ofStatement::execute() - Use
prepare()instead ofStatement::prepare()
§Example
Implementations§
Source§impl Connection
impl Connection
Sourcepub async fn from_params(
params: ConnectionParams,
) -> Result<Self, ConnectionError>
pub async fn from_params( params: ConnectionParams, ) -> Result<Self, ConnectionError>
Create a connection from connection parameters.
This establishes a connection to the Exasol database using WebSocket transport, authenticates the user, and creates a session.
§Arguments
params- Connection parameters
§Returns
A connected Connection instance.
§Errors
Returns ConnectionError if the connection or authentication fails.
Sourcepub fn builder() -> ConnectionBuilder
pub fn builder() -> ConnectionBuilder
Sourcepub fn create_statement(&self, sql: impl Into<String>) -> Statement
pub fn create_statement(&self, sql: impl Into<String>) -> Statement
Sourcepub async fn execute_statement(
&mut self,
stmt: &Statement,
) -> Result<ResultSet, QueryError>
pub async fn execute_statement( &mut self, stmt: &Statement, ) -> Result<ResultSet, QueryError>
Sourcepub async fn execute_statement_update(
&mut self,
stmt: &Statement,
) -> Result<i64, QueryError>
pub async fn execute_statement_update( &mut self, stmt: &Statement, ) -> Result<i64, QueryError>
Sourcepub async fn prepare(
&mut self,
sql: impl Into<String>,
) -> Result<PreparedStatement, QueryError>
pub async fn prepare( &mut self, sql: impl Into<String>, ) -> Result<PreparedStatement, QueryError>
Create a prepared statement for parameterized query execution.
This creates a server-side prepared statement that can be executed multiple times with different parameter values.
§Arguments
sql- SQL statement with parameter placeholders (?)
§Returns
A PreparedStatement ready for parameter binding and execution.
§Errors
Returns QueryError if preparation fails.
§Example
Sourcepub async fn execute_prepared(
&mut self,
stmt: &PreparedStatement,
) -> Result<ResultSet, QueryError>
pub async fn execute_prepared( &mut self, stmt: &PreparedStatement, ) -> Result<ResultSet, QueryError>
Sourcepub async fn execute_prepared_update(
&mut self,
stmt: &PreparedStatement,
) -> Result<i64, QueryError>
pub async fn execute_prepared_update( &mut self, stmt: &PreparedStatement, ) -> Result<i64, QueryError>
Sourcepub async fn close_prepared(
&mut self,
stmt: PreparedStatement,
) -> Result<(), QueryError>
pub async fn close_prepared( &mut self, stmt: PreparedStatement, ) -> Result<(), QueryError>
Sourcepub async fn query(
&mut self,
sql: impl Into<String>,
) -> Result<Vec<RecordBatch>, QueryError>
pub async fn query( &mut self, sql: impl Into<String>, ) -> Result<Vec<RecordBatch>, QueryError>
Sourcepub async fn execute_update(
&mut self,
sql: impl Into<String>,
) -> Result<i64, QueryError>
pub async fn execute_update( &mut self, sql: impl Into<String>, ) -> Result<i64, QueryError>
Sourcepub async fn begin_transaction(&mut self) -> Result<(), QueryError>
pub async fn begin_transaction(&mut self) -> Result<(), QueryError>
Sourcepub async fn commit(&mut self) -> Result<(), QueryError>
pub async fn commit(&mut self) -> Result<(), QueryError>
Sourcepub async fn rollback(&mut self) -> Result<(), QueryError>
pub async fn rollback(&mut self) -> Result<(), QueryError>
Sourcepub fn in_transaction(&self) -> bool
pub fn in_transaction(&self) -> bool
Check if a transaction is currently active.
§Returns
true if a transaction is active, false otherwise.
Sourcepub async fn current_schema(&self) -> Option<String>
pub async fn current_schema(&self) -> Option<String>
Sourcepub async fn set_schema(
&mut self,
schema: impl Into<String>,
) -> Result<(), QueryError>
pub async fn set_schema( &mut self, schema: impl Into<String>, ) -> Result<(), QueryError>
Sourcepub async fn get_catalogs(&mut self) -> Result<ResultSet, QueryError>
pub async fn get_catalogs(&mut self) -> Result<ResultSet, QueryError>
Sourcepub async fn get_schemas(
&mut self,
catalog: Option<&str>,
) -> Result<ResultSet, QueryError>
pub async fn get_schemas( &mut self, catalog: Option<&str>, ) -> Result<ResultSet, QueryError>
Sourcepub async fn get_tables(
&mut self,
catalog: Option<&str>,
schema: Option<&str>,
table: Option<&str>,
) -> Result<ResultSet, QueryError>
pub async fn get_tables( &mut self, catalog: Option<&str>, schema: Option<&str>, table: Option<&str>, ) -> Result<ResultSet, QueryError>
Sourcepub async fn get_columns(
&mut self,
catalog: Option<&str>,
schema: Option<&str>,
table: Option<&str>,
column: Option<&str>,
) -> Result<ResultSet, QueryError>
pub async fn get_columns( &mut self, catalog: Option<&str>, schema: Option<&str>, table: Option<&str>, column: Option<&str>, ) -> Result<ResultSet, QueryError>
Sourcepub fn session_id(&self) -> &str
pub fn session_id(&self) -> &str
Sourcepub fn params(&self) -> &ConnectionParams
pub fn params(&self) -> &ConnectionParams
Sourcepub async fn close(self) -> Result<(), ConnectionError>
pub async fn close(self) -> Result<(), ConnectionError>
Sourcepub async fn import_csv_from_file(
&mut self,
table: &str,
file_path: &Path,
options: CsvImportOptions,
) -> Result<u64, ImportError>
pub async fn import_csv_from_file( &mut self, table: &str, file_path: &Path, options: CsvImportOptions, ) -> Result<u64, ImportError>
Import CSV data from a file into an Exasol table.
This method reads CSV data from the specified file and imports it into the target table using Exasol’s HTTP transport layer.
§Arguments
table- Name of the target tablefile_path- Path to the CSV fileoptions- Import options
§Returns
The number of rows imported on success.
§Errors
Returns ImportError if the import fails.
§Example
Sourcepub async fn import_csv_from_stream<R>(
&mut self,
table: &str,
reader: R,
options: CsvImportOptions,
) -> Result<u64, ImportError>
pub async fn import_csv_from_stream<R>( &mut self, table: &str, reader: R, options: CsvImportOptions, ) -> Result<u64, ImportError>
Import CSV data from an async reader into an Exasol table.
This method reads CSV data from an async reader and imports it into the target table using Exasol’s HTTP transport layer.
§Arguments
table- Name of the target tablereader- Async reader providing CSV dataoptions- Import options
§Returns
The number of rows imported on success.
§Errors
Returns ImportError if the import fails.
Sourcepub async fn import_csv_from_iter<I, T, S>(
&mut self,
table: &str,
rows: I,
options: CsvImportOptions,
) -> Result<u64, ImportError>
pub async fn import_csv_from_iter<I, T, S>( &mut self, table: &str, rows: I, options: CsvImportOptions, ) -> Result<u64, ImportError>
Import CSV data from an iterator into an Exasol table.
This method converts iterator rows to CSV format and imports them into the target table using Exasol’s HTTP transport layer.
§Arguments
table- Name of the target tablerows- Iterator of rows, where each row is an iterator of field valuesoptions- Import options
§Returns
The number of rows imported on success.
§Errors
Returns ImportError if the import fails.
§Example
Sourcepub async fn export_csv_to_file(
&mut self,
source: ExportSource,
file_path: &Path,
options: CsvExportOptions,
) -> Result<u64, ExportError>
pub async fn export_csv_to_file( &mut self, source: ExportSource, file_path: &Path, options: CsvExportOptions, ) -> Result<u64, ExportError>
Export data from an Exasol table or query to a CSV file.
This method exports data from the specified source to a CSV file using Exasol’s HTTP transport layer.
§Arguments
source- The data source (table or query)file_path- Path to the output fileoptions- Export options
§Returns
The number of rows exported on success.
§Errors
Returns ExportError if the export fails.
§Example
Sourcepub async fn export_csv_to_stream<W>(
&mut self,
source: ExportSource,
writer: W,
options: CsvExportOptions,
) -> Result<u64, ExportError>where
W: AsyncWrite + Unpin,
pub async fn export_csv_to_stream<W>(
&mut self,
source: ExportSource,
writer: W,
options: CsvExportOptions,
) -> Result<u64, ExportError>where
W: AsyncWrite + Unpin,
Export data from an Exasol table or query to an async writer.
This method exports data from the specified source to an async writer using Exasol’s HTTP transport layer.
§Arguments
source- The data source (table or query)writer- Async writer to write the CSV data tooptions- Export options
§Returns
The number of rows exported on success.
§Errors
Returns ExportError if the export fails.
Sourcepub async fn export_csv_to_list(
&mut self,
source: ExportSource,
options: CsvExportOptions,
) -> Result<Vec<Vec<String>>, ExportError>
pub async fn export_csv_to_list( &mut self, source: ExportSource, options: CsvExportOptions, ) -> Result<Vec<Vec<String>>, ExportError>
Export data from an Exasol table or query to an in-memory list of rows.
Each row is represented as a vector of string values.
§Arguments
source- The data source (table or query)options- Export options
§Returns
A vector of rows, where each row is a vector of column values.
§Errors
Returns ExportError if the export fails.
§Example
Sourcepub async fn import_csv_from_files<S: IntoFileSources>(
&mut self,
table: &str,
paths: S,
options: CsvImportOptions,
) -> Result<u64, ImportError>
pub async fn import_csv_from_files<S: IntoFileSources>( &mut self, table: &str, paths: S, options: CsvImportOptions, ) -> Result<u64, ImportError>
Import multiple CSV files in parallel into an Exasol table.
This method reads CSV data from multiple files and imports them into the target table using parallel HTTP transport connections. Each file gets its own connection with a unique internal address.
For a single file, this method delegates to import_csv_from_file.
§Arguments
table- Name of the target tablepaths- File paths (accepts single path, Vec, array, or slice)options- Import options
§Returns
The number of rows imported on success.
§Errors
Returns ImportError if the import fails. Uses fail-fast semantics.
§Example
use exarrow_rs::adbc::Connection;
use exarrow_rs::import::CsvImportOptions;
use std::path::PathBuf;
let files = vec![
PathBuf::from("/data/part1.csv"),
PathBuf::from("/data/part2.csv"),
];
let options = CsvImportOptions::default();
let rows = conn.import_csv_from_files("my_table", files, options).await?;Sourcepub async fn import_from_parquet(
&mut self,
table: &str,
file_path: &Path,
options: ParquetImportOptions,
) -> Result<u64, ImportError>
pub async fn import_from_parquet( &mut self, table: &str, file_path: &Path, options: ParquetImportOptions, ) -> Result<u64, ImportError>
Import data from a Parquet file into an Exasol table.
This method reads a Parquet file, converts the data to CSV format, and imports it into the target table using Exasol’s HTTP transport layer.
§Arguments
table- Name of the target tablefile_path- Path to the Parquet fileoptions- Import options
§Returns
The number of rows imported on success.
§Errors
Returns ImportError if the import fails.
§Example
Sourcepub async fn import_parquet_from_files<S: IntoFileSources>(
&mut self,
table: &str,
paths: S,
options: ParquetImportOptions,
) -> Result<u64, ImportError>
pub async fn import_parquet_from_files<S: IntoFileSources>( &mut self, table: &str, paths: S, options: ParquetImportOptions, ) -> Result<u64, ImportError>
Import multiple Parquet files in parallel into an Exasol table.
This method converts each Parquet file to CSV format concurrently, then streams the data through parallel HTTP transport connections.
For a single file, this method delegates to import_from_parquet.
§Arguments
table- Name of the target tablepaths- File paths (accepts single path, Vec, array, or slice)options- Import options
§Returns
The number of rows imported on success.
§Errors
Returns ImportError if the import fails. Uses fail-fast semantics.
§Example
use exarrow_rs::adbc::Connection;
use exarrow_rs::import::ParquetImportOptions;
use std::path::PathBuf;
let files = vec![
PathBuf::from("/data/part1.parquet"),
PathBuf::from("/data/part2.parquet"),
];
let options = ParquetImportOptions::default();
let rows = conn.import_parquet_from_files("my_table", files, options).await?;Sourcepub async fn export_to_parquet(
&mut self,
source: ExportSource,
file_path: &Path,
options: ParquetExportOptions,
) -> Result<u64, ExportError>
pub async fn export_to_parquet( &mut self, source: ExportSource, file_path: &Path, options: ParquetExportOptions, ) -> Result<u64, ExportError>
Export data from an Exasol table or query to a Parquet file.
This method exports data from the specified source to a Parquet file. The data is first received as CSV from Exasol, then converted to Parquet format.
§Arguments
source- The data source (table or query)file_path- Path to the output Parquet fileoptions- Export options
§Returns
The number of rows exported on success.
§Errors
Returns ExportError if the export fails.
§Example
Sourcepub async fn import_from_record_batch(
&mut self,
table: &str,
batch: &RecordBatch,
options: ArrowImportOptions,
) -> Result<u64, ImportError>
pub async fn import_from_record_batch( &mut self, table: &str, batch: &RecordBatch, options: ArrowImportOptions, ) -> Result<u64, ImportError>
Import data from an Arrow RecordBatch into an Exasol table.
This method converts the RecordBatch to CSV format and imports it into the target table using Exasol’s HTTP transport layer.
§Arguments
table- Name of the target tablebatch- The RecordBatch to importoptions- Import options
§Returns
The number of rows imported on success.
§Errors
Returns ImportError if the import fails.
§Example
Sourcepub async fn import_from_record_batches<I>(
&mut self,
table: &str,
batches: I,
options: ArrowImportOptions,
) -> Result<u64, ImportError>where
I: IntoIterator<Item = RecordBatch>,
pub async fn import_from_record_batches<I>(
&mut self,
table: &str,
batches: I,
options: ArrowImportOptions,
) -> Result<u64, ImportError>where
I: IntoIterator<Item = RecordBatch>,
Import data from multiple Arrow RecordBatches into an Exasol table.
This method converts each RecordBatch to CSV format and imports them into the target table using Exasol’s HTTP transport layer.
§Arguments
table- Name of the target tablebatches- An iterator of RecordBatches to importoptions- Import options
§Returns
The number of rows imported on success.
§Errors
Returns ImportError if the import fails.
Sourcepub async fn import_from_arrow_ipc<R>(
&mut self,
table: &str,
reader: R,
options: ArrowImportOptions,
) -> Result<u64, ImportError>
pub async fn import_from_arrow_ipc<R>( &mut self, table: &str, reader: R, options: ArrowImportOptions, ) -> Result<u64, ImportError>
Import data from an Arrow IPC file/stream into an Exasol table.
This method reads Arrow IPC format data, converts it to CSV, and imports it into the target table using Exasol’s HTTP transport layer.
§Arguments
table- Name of the target tablereader- An async reader containing Arrow IPC dataoptions- Import options
§Returns
The number of rows imported on success.
§Errors
Returns ImportError if the import fails.
§Example
Sourcepub async fn export_to_record_batches(
&mut self,
source: ExportSource,
options: ArrowExportOptions,
) -> Result<Vec<RecordBatch>, ExportError>
pub async fn export_to_record_batches( &mut self, source: ExportSource, options: ArrowExportOptions, ) -> Result<Vec<RecordBatch>, ExportError>
Export data from an Exasol table or query to Arrow RecordBatches.
This method exports data from the specified source and converts it to Arrow RecordBatches.
§Arguments
source- The data source (table or query)options- Export options
§Returns
A vector of RecordBatches on success.
§Errors
Returns ExportError if the export fails.
§Example
Sourcepub async fn export_to_arrow_ipc(
&mut self,
source: ExportSource,
file_path: &Path,
options: ArrowExportOptions,
) -> Result<u64, ExportError>
pub async fn export_to_arrow_ipc( &mut self, source: ExportSource, file_path: &Path, options: ArrowExportOptions, ) -> Result<u64, ExportError>
Export data from an Exasol table or query to an Arrow IPC file.
This method exports data from the specified source to an Arrow IPC file.
§Arguments
source- The data source (table or query)file_path- Path to the output Arrow IPC fileoptions- Export options
§Returns
The number of rows exported on success.
§Errors
Returns ExportError if the export fails.
§Example
Sourcepub fn blocking_import_csv_from_file(
&mut self,
table: &str,
file_path: &Path,
options: CsvImportOptions,
) -> Result<u64, ImportError>
pub fn blocking_import_csv_from_file( &mut self, table: &str, file_path: &Path, options: CsvImportOptions, ) -> Result<u64, ImportError>
Import CSV data from a file into an Exasol table (blocking).
This is a synchronous wrapper around import_csv_from_file
for use in non-async contexts.
§Arguments
table- Name of the target tablefile_path- Path to the CSV fileoptions- Import options
§Returns
The number of rows imported on success.
§Errors
Returns ImportError if the import fails.
§Example
Sourcepub fn blocking_import_csv_from_files<S: IntoFileSources>(
&mut self,
table: &str,
paths: S,
options: CsvImportOptions,
) -> Result<u64, ImportError>
pub fn blocking_import_csv_from_files<S: IntoFileSources>( &mut self, table: &str, paths: S, options: CsvImportOptions, ) -> Result<u64, ImportError>
Import multiple CSV files in parallel into an Exasol table (blocking).
This is a synchronous wrapper around import_csv_from_files
for use in non-async contexts.
§Arguments
table- Name of the target tablepaths- File paths (accepts single path, Vec, array, or slice)options- Import options
§Returns
The number of rows imported on success.
§Errors
Returns ImportError if the import fails.
Sourcepub fn blocking_import_from_parquet(
&mut self,
table: &str,
file_path: &Path,
options: ParquetImportOptions,
) -> Result<u64, ImportError>
pub fn blocking_import_from_parquet( &mut self, table: &str, file_path: &Path, options: ParquetImportOptions, ) -> Result<u64, ImportError>
Import data from a Parquet file into an Exasol table (blocking).
This is a synchronous wrapper around import_from_parquet
for use in non-async contexts.
§Arguments
table- Name of the target tablefile_path- Path to the Parquet fileoptions- Import options
§Returns
The number of rows imported on success.
§Errors
Returns ImportError if the import fails.
§Example
Sourcepub fn blocking_import_parquet_from_files<S: IntoFileSources>(
&mut self,
table: &str,
paths: S,
options: ParquetImportOptions,
) -> Result<u64, ImportError>
pub fn blocking_import_parquet_from_files<S: IntoFileSources>( &mut self, table: &str, paths: S, options: ParquetImportOptions, ) -> Result<u64, ImportError>
Import multiple Parquet files in parallel into an Exasol table (blocking).
This is a synchronous wrapper around import_parquet_from_files
for use in non-async contexts.
§Arguments
table- Name of the target tablepaths- File paths (accepts single path, Vec, array, or slice)options- Import options
§Returns
The number of rows imported on success.
§Errors
Returns ImportError if the import fails.
Sourcepub fn blocking_import_from_record_batch(
&mut self,
table: &str,
batch: &RecordBatch,
options: ArrowImportOptions,
) -> Result<u64, ImportError>
pub fn blocking_import_from_record_batch( &mut self, table: &str, batch: &RecordBatch, options: ArrowImportOptions, ) -> Result<u64, ImportError>
Import data from an Arrow RecordBatch into an Exasol table (blocking).
This is a synchronous wrapper around import_from_record_batch
for use in non-async contexts.
§Arguments
table- Name of the target tablebatch- The RecordBatch to importoptions- Import options
§Returns
The number of rows imported on success.
§Errors
Returns ImportError if the import fails.
§Example
Sourcepub fn blocking_import_from_arrow_ipc(
&mut self,
table: &str,
file_path: &Path,
options: ArrowImportOptions,
) -> Result<u64, ImportError>
pub fn blocking_import_from_arrow_ipc( &mut self, table: &str, file_path: &Path, options: ArrowImportOptions, ) -> Result<u64, ImportError>
Import data from an Arrow IPC file into an Exasol table (blocking).
This is a synchronous wrapper around import_from_arrow_ipc
for use in non-async contexts.
Note: This method requires a synchronous reader that implements std::io::Read.
The data will be read into memory before being imported.
§Arguments
table- Name of the target tablefile_path- Path to the Arrow IPC fileoptions- Import options
§Returns
The number of rows imported on success.
§Errors
Returns ImportError if the import fails.
§Example
Sourcepub fn blocking_export_csv_to_file(
&mut self,
source: ExportSource,
file_path: &Path,
options: CsvExportOptions,
) -> Result<u64, ExportError>
pub fn blocking_export_csv_to_file( &mut self, source: ExportSource, file_path: &Path, options: CsvExportOptions, ) -> Result<u64, ExportError>
Export data from an Exasol table or query to a CSV file (blocking).
This is a synchronous wrapper around export_csv_to_file
for use in non-async contexts.
§Arguments
source- The data source (table or query)file_path- Path to the output fileoptions- Export options
§Returns
The number of rows exported on success.
§Errors
Returns ExportError if the export fails.
§Example
Sourcepub fn blocking_export_to_parquet(
&mut self,
source: ExportSource,
file_path: &Path,
options: ParquetExportOptions,
) -> Result<u64, ExportError>
pub fn blocking_export_to_parquet( &mut self, source: ExportSource, file_path: &Path, options: ParquetExportOptions, ) -> Result<u64, ExportError>
Export data from an Exasol table or query to a Parquet file (blocking).
This is a synchronous wrapper around export_to_parquet
for use in non-async contexts.
§Arguments
source- The data source (table or query)file_path- Path to the output Parquet fileoptions- Export options
§Returns
The number of rows exported on success.
§Errors
Returns ExportError if the export fails.
§Example
Sourcepub fn blocking_export_to_record_batches(
&mut self,
source: ExportSource,
options: ArrowExportOptions,
) -> Result<Vec<RecordBatch>, ExportError>
pub fn blocking_export_to_record_batches( &mut self, source: ExportSource, options: ArrowExportOptions, ) -> Result<Vec<RecordBatch>, ExportError>
Export data from an Exasol table or query to Arrow RecordBatches (blocking).
This is a synchronous wrapper around export_to_record_batches
for use in non-async contexts.
§Arguments
source- The data source (table or query)options- Export options
§Returns
A vector of RecordBatches on success.
§Errors
Returns ExportError if the export fails.
§Example
Sourcepub fn blocking_export_to_arrow_ipc(
&mut self,
source: ExportSource,
file_path: &Path,
options: ArrowExportOptions,
) -> Result<u64, ExportError>
pub fn blocking_export_to_arrow_ipc( &mut self, source: ExportSource, file_path: &Path, options: ArrowExportOptions, ) -> Result<u64, ExportError>
Export data from an Exasol table or query to an Arrow IPC file (blocking).
This is a synchronous wrapper around export_to_arrow_ipc
for use in non-async contexts.
§Arguments
source- The data source (table or query)file_path- Path to the output Arrow IPC fileoptions- Export options
§Returns
The number of rows exported on success.
§Errors
Returns ExportError if the export fails.