Expand description
§Using buffers to fetch results
The most efficient way to query results is not query an ODBC data source row by row, but to
ask for a whole bulk of rows at once. The ODBC driver and driver manager will then fill these
row sets into buffers which have been previously bound. This is also the most efficient way to
query a single row many times for many queries, if the application can reuse the bound buffer.
This crate allows you to provide your own buffers by implementing the crate::RowSetBuffer
trait. That however requires unsafe
code.
This crate also provides three implementations of the crate::RowSetBuffer
trait, ready to be
used in safe code:
crate::buffers::ColumnarBuffer
: Binds to the result set column wise. This is usually helpful in dataengineering or data sciense tasks. This buffer type can be used in situations there the schema of the queried data is known at compile time, as well as for generic applications which do work with wide range of different data. Checkt the struct documentation for examples.crate::buffers::TextRowSet
: Queries all data as text bound in columns. Since the columns are homogeneous, you can also use this, to iterate row wise over the buffer. Excellent if you want to print the contents of a table, or are for any reason only interessted in the text representation of the values.crate::buffers::RowVec
: A good choice if you know the schema at compile time and your application logic is build in a row by row fashion, rather than column by column.
Structs§
- A buffer intended to be bound to a column of a cursor. Elements of the buffer will contain a variable amount of bytes up to a maximum length. Since elements of this type have variable length an additional indicator buffer is also maintained, whether the column is nullable or not. Therefore this buffer type is used for variable sized binary data whether it is nullable or not.
- Iterator over a binary column. See
crate::buffers::BinColumn
- A view to a mutable array parameter text buffer, which allows for filling the buffer with values.
- A columnar buffer intended to be bound with crate::Cursor::bind_buffer in order to obtain results from a cursor.
- Iterates over the elements of a column buffer. Returned by
crate::buffers::ColumnarBuffer::column
as part of ancrate::buffers::AnySlice
. - Used to fill a column buffer with an iterator. Returned by
crate::ColumnarBulkInserter::column_mut
as part of ancrate::buffers::AnySliceMut
. - A row wise buffer intended to be bound with crate::Cursor::bind_buffer in order to obtain results from a cursor.
- A buffer intended to be bound to a column of a cursor. Elements of the buffer will contain a variable amount of characters up to a maximum string length. Since most SQL types have a string representation this buffer can be bound to a column of almost any type, ODBC driver and driver manager should take care of the conversion. Since elements of this type have variable length an indicator buffer needs to be bound, whether the column is nullable or not, and therefore does not matter for this buffer.
- Iterator over a text column. See
TextColumnView::iter
- A view to a mutable array parameter text buffer, which allows for filling the buffer with values.
- Allows read only access to the valid part of a text column.
Enums§
- Buffer holding a single column of either a result set or paramater
- A borrowed view on the valid rows in a column of a
crate::buffers::ColumnarBuffer
. - A mutable slice of an input buffer, with runtime type information. Edit values in this slice in order to send parameters in bulk to a database.
- Describes a column of a
crate::buffers::ColumnarBuffer
. - Indicates existence and length of a value.
Traits§
- A buffer for a single column intended to be used together with
ColumnarBuffer
. FetchRow
s can be bound to acrate::Cursor
to enable row wise (bulk) fetching of data as opposed to column wise fetching. Since all rows are bound to a C-API in a contigious block of memory the row itself should be representable as such. Concretly that means that types likeString
can not be supported directly byFetchRow
s for efficient bulk fetching, due to the fact it points to data on the heap.- Can be used as a member of a
FetchRow
and bound to a column during row wise fetching. - Can either be extracted as a slice or a
NullableSlice
from anAnySlice
. This allows the user to avoid matching on all possibile variants of anAnySlice
in case the buffered type is known at compile time.
Type Aliases§
- A column buffer for character data. The actual encoding used may depend on your system locale.
- Flexible columnar buffer implementation. Bind this to a cursor to fetch values in bulk, or pass this as a parameter to a statement, to submit many parameters at once.
- This row set binds a string buffer to each column, which is large enough to hold the maximum length string representation for each element in the row set at once.
- This buffer uses wide characters which implies UTF-16 encoding. UTF-8 encoding is preferable for most applications, but contrary to its sibling
crate::buffers::CharColumn
this buffer types implied encoding does not depend on the system locale.