Skip to main content

Connection

Struct Connection 

Source
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 of Statement::execute()
  • Use prepare() instead of Statement::prepare()

§Example

Implementations§

Source§

impl Connection

Source

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.

Source

pub fn builder() -> ConnectionBuilder

Create a builder for constructing a connection.

§Returns

A ConnectionBuilder instance.

§Example
Source

pub fn create_statement(&self, sql: impl Into<String>) -> Statement

Create a new statement for executing SQL.

Statement is now a pure data container. Use execute_statement() to execute it.

§Arguments
  • sql - SQL query text
§Returns

A Statement instance ready for execution via execute_statement().

§Example
Source

pub async fn execute_statement( &mut self, stmt: &Statement, ) -> Result<ResultSet, QueryError>

Execute a statement and return results.

§Arguments
  • stmt - Statement to execute
§Returns

A ResultSet containing the query results.

§Errors

Returns QueryError if execution fails or times out.

§Example
Source

pub async fn execute_statement_update( &mut self, stmt: &Statement, ) -> Result<i64, QueryError>

Execute a statement and return the row count (for non-SELECT statements).

§Arguments
  • stmt - Statement to execute
§Returns

The number of rows affected.

§Errors

Returns QueryError if execution fails or if statement is a SELECT.

§Example
Source

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
Source

pub async fn execute_prepared( &mut self, stmt: &PreparedStatement, ) -> Result<ResultSet, QueryError>

Execute a prepared statement and return results.

§Arguments
  • stmt - Prepared statement to execute
§Returns

A ResultSet containing the query results.

§Errors

Returns QueryError if execution fails.

§Example
Source

pub async fn execute_prepared_update( &mut self, stmt: &PreparedStatement, ) -> Result<i64, QueryError>

Execute a prepared statement and return the number of affected rows.

Use this for INSERT, UPDATE, DELETE statements.

§Arguments
  • stmt - Prepared statement to execute
§Returns

The number of rows affected.

§Errors

Returns QueryError if execution fails or statement returns a result set.

Source

pub async fn close_prepared( &mut self, stmt: PreparedStatement, ) -> Result<(), QueryError>

Close a prepared statement and release server-side resources.

§Arguments
  • stmt - Prepared statement to close (consumed)
§Errors

Returns QueryError if closing fails.

§Example
Source

pub async fn execute( &mut self, sql: impl Into<String>, ) -> Result<ResultSet, QueryError>

Execute a SQL query and return results.

This is a convenience method that creates a statement and executes it.

§Arguments
  • sql - SQL query text
§Returns

A ResultSet containing the query results.

§Errors

Returns QueryError if execution fails.

§Example
Source

pub async fn query( &mut self, sql: impl Into<String>, ) -> Result<Vec<RecordBatch>, QueryError>

Execute a SQL query and return all results as RecordBatches.

This is a convenience method that fetches all results into memory.

§Arguments
  • sql - SQL query text
§Returns

A vector of RecordBatch instances.

§Errors

Returns QueryError if execution fails.

§Example
Source

pub async fn execute_update( &mut self, sql: impl Into<String>, ) -> Result<i64, QueryError>

Execute a non-SELECT statement and return the row count.

§Arguments
  • sql - SQL statement (INSERT, UPDATE, DELETE, etc.)
§Returns

The number of rows affected.

§Errors

Returns QueryError if execution fails.

§Example
Source

pub async fn begin_transaction(&mut self) -> Result<(), QueryError>

Begin a transaction.

§Errors

Returns QueryError if a transaction is already active or if the operation fails.

§Example
Source

pub async fn commit(&mut self) -> Result<(), QueryError>

Commit the current transaction.

§Errors

Returns QueryError if no transaction is active or if the operation fails.

§Example
Source

pub async fn rollback(&mut self) -> Result<(), QueryError>

Rollback the current transaction.

§Errors

Returns QueryError if no transaction is active or if the operation fails.

§Example
Source

pub fn in_transaction(&self) -> bool

Check if a transaction is currently active.

§Returns

true if a transaction is active, false otherwise.

Source

pub async fn current_schema(&self) -> Option<String>

Get the current schema.

§Returns

The current schema name, or None if no schema is set.

Source

pub async fn set_schema( &mut self, schema: impl Into<String>, ) -> Result<(), QueryError>

Set the current schema.

§Arguments
  • schema - The schema name to set
§Errors

Returns QueryError if the operation fails.

§Example
Source

pub async fn get_catalogs(&mut self) -> Result<ResultSet, QueryError>

Get metadata about catalogs.

§Returns

A ResultSet containing catalog metadata.

§Errors

Returns QueryError if the operation fails.

Source

pub async fn get_schemas( &mut self, catalog: Option<&str>, ) -> Result<ResultSet, QueryError>

Get metadata about schemas.

§Arguments
  • catalog - Optional catalog name filter
§Returns

A ResultSet containing schema metadata.

§Errors

Returns QueryError if the operation fails.

Source

pub async fn get_tables( &mut self, catalog: Option<&str>, schema: Option<&str>, table: Option<&str>, ) -> Result<ResultSet, QueryError>

Get metadata about tables.

§Arguments
  • catalog - Optional catalog name filter
  • schema - Optional schema name filter
  • table - Optional table name filter
§Returns

A ResultSet containing table metadata.

§Errors

Returns QueryError if the operation fails.

Source

pub async fn get_columns( &mut self, catalog: Option<&str>, schema: Option<&str>, table: Option<&str>, column: Option<&str>, ) -> Result<ResultSet, QueryError>

Get metadata about columns.

§Arguments
  • catalog - Optional catalog name filter
  • schema - Optional schema name filter
  • table - Optional table name filter
  • column - Optional column name filter
§Returns

A ResultSet containing column metadata.

§Errors

Returns QueryError if the operation fails.

Source

pub fn session_id(&self) -> &str

Get session information.

§Returns

The session ID.

Source

pub fn params(&self) -> &ConnectionParams

Get connection parameters.

§Returns

A reference to the connection parameters.

Source

pub async fn is_closed(&self) -> bool

Check if the connection is closed.

§Returns

true if the connection is closed, false otherwise.

Source

pub async fn close(self) -> Result<(), ConnectionError>

Close the connection.

This closes the session and transport layer.

§Errors

Returns ConnectionError if closing fails.

§Example
Source

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 table
  • file_path - Path to the CSV file
  • options - Import options
§Returns

The number of rows imported on success.

§Errors

Returns ImportError if the import fails.

§Example
Source

pub async fn import_csv_from_stream<R>( &mut self, table: &str, reader: R, options: CsvImportOptions, ) -> Result<u64, ImportError>
where R: AsyncRead + Unpin + Send + 'static,

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 table
  • reader - Async reader providing CSV data
  • options - Import options
§Returns

The number of rows imported on success.

§Errors

Returns ImportError if the import fails.

Source

pub async fn import_csv_from_iter<I, T, S>( &mut self, table: &str, rows: I, options: CsvImportOptions, ) -> Result<u64, ImportError>
where I: IntoIterator<Item = T> + Send + 'static, T: IntoIterator<Item = S> + Send, S: AsRef<str>,

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 table
  • rows - Iterator of rows, where each row is an iterator of field values
  • options - Import options
§Returns

The number of rows imported on success.

§Errors

Returns ImportError if the import fails.

§Example
Source

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 file
  • options - Export options
§Returns

The number of rows exported on success.

§Errors

Returns ExportError if the export fails.

§Example
Source

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 to
  • options - Export options
§Returns

The number of rows exported on success.

§Errors

Returns ExportError if the export fails.

Source

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
Source

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 table
  • paths - 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?;
Source

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 table
  • file_path - Path to the Parquet file
  • options - Import options
§Returns

The number of rows imported on success.

§Errors

Returns ImportError if the import fails.

§Example
Source

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 table
  • paths - 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?;
Source

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 file
  • options - Export options
§Returns

The number of rows exported on success.

§Errors

Returns ExportError if the export fails.

§Example
Source

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 table
  • batch - The RecordBatch to import
  • options - Import options
§Returns

The number of rows imported on success.

§Errors

Returns ImportError if the import fails.

§Example
Source

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 table
  • batches - An iterator of RecordBatches to import
  • options - Import options
§Returns

The number of rows imported on success.

§Errors

Returns ImportError if the import fails.

Source

pub async fn import_from_arrow_ipc<R>( &mut self, table: &str, reader: R, options: ArrowImportOptions, ) -> Result<u64, ImportError>
where R: AsyncRead + Unpin + Send,

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 table
  • reader - An async reader containing Arrow IPC data
  • options - Import options
§Returns

The number of rows imported on success.

§Errors

Returns ImportError if the import fails.

§Example
Source

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
Source

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 file
  • options - Export options
§Returns

The number of rows exported on success.

§Errors

Returns ExportError if the export fails.

§Example
Source

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 table
  • file_path - Path to the CSV file
  • options - Import options
§Returns

The number of rows imported on success.

§Errors

Returns ImportError if the import fails.

§Example
Source

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 table
  • paths - 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.

Source

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 table
  • file_path - Path to the Parquet file
  • options - Import options
§Returns

The number of rows imported on success.

§Errors

Returns ImportError if the import fails.

§Example
Source

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 table
  • paths - 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.

Source

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 table
  • batch - The RecordBatch to import
  • options - Import options
§Returns

The number of rows imported on success.

§Errors

Returns ImportError if the import fails.

§Example
Source

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 table
  • file_path - Path to the Arrow IPC file
  • options - Import options
§Returns

The number of rows imported on success.

§Errors

Returns ImportError if the import fails.

§Example
Source

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 file
  • options - Export options
§Returns

The number of rows exported on success.

§Errors

Returns ExportError if the export fails.

§Example
Source

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 file
  • options - Export options
§Returns

The number of rows exported on success.

§Errors

Returns ExportError if the export fails.

§Example
Source

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
Source

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 file
  • options - Export options
§Returns

The number of rows exported on success.

§Errors

Returns ExportError if the export fails.

§Example

Trait Implementations§

Source§

impl Debug for Connection

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V