pub struct Connection { /* private fields */ }Expand description
A connection to ClickHouse with health status tracking.
This wrapper around clickhouse::Client adds tracking of whether the connection
is still valid. It implements Deref and DerefMut so it can be used transparently
like a clickhouse::Client.
Implementations§
Methods from Deref<Target = Client>§
Sourcepub async fn insert<T>(&self, table: &str) -> Result<Insert<T>, Error>where
T: Row,
pub async fn insert<T>(&self, table: &str) -> Result<Insert<T>, Error>where
T: Row,
Starts a new INSERT statement.
§Validation
If validation is enabled (default), RowBinaryWithNamesAndTypes input format is used.
When Client::insert method is called for this table for the first time,
it will fetch the table schema from the server, allowing to validate the serialized rows,
as well as write the names and types of the columns in the request header.
Fetching the schema will happen only once per table,
as the schema is cached by the client internally.
With disabled validation, the schema is not fetched,
and the rows serialized with RowBinary input format.
§Panics
If T has unnamed fields, e.g. tuples.
Sourcepub async fn clear_cached_metadata(&self)
pub async fn clear_cached_metadata(&self)
Clear table metadata that was previously received and cached.
Insert uses cached metadata when sending data with validation.
If the table schema changes, this metadata needs to re-fetched.
This method clears the metadata cache, causing future insert queries to re-fetch metadata.
This applies to all cloned instances of this Client (using the same URL and database)
as well.
This may need to wait to acquire a lock if a query is concurrently writing into the cache.
Cancel-safe.