|
nanodbc
A small C++ wrapper for the native C ODBC API
|
Convenience functions. More...
Namespaces | |
| namespace | nanodbc::detail |
| Implementation details, not part of the interface. | |
Classes | |
| struct | nanodbc::driver |
| Information on a configured ODBC driver. More... | |
| struct | nanodbc::datasource |
| A data source name registered with the driver manager. More... | |
Functions | |
| std::list< driver > | nanodbc::list_drivers () |
| Returns a list of ODBC drivers on your system. | |
| std::list< datasource > | nanodbc::list_datasources () |
| Returns a list of ODBC data sources on your system. | |
| result | nanodbc::execute (connection &conn, string const &query, long batch_operations=1, long timeout=0) |
| Immediately opens, prepares, and executes the given query directly on the given connection. | |
| void | nanodbc::just_execute (connection &conn, string const &query, long batch_operations=1, long timeout=0) |
| Opens, prepares, and executes query directly without creating result object. | |
| template<class Rows , class... Accessors> | |
| void | nanodbc::bind_rows (statement &stmt, Rows const &rows, Accessors const &... accessors) |
| Binds a range of rows, a parameter at a time. | |
| result | nanodbc::execute (statement &stmt, long batch_operations=1) |
| Execute the previously prepared query now. | |
| void | nanodbc::just_execute (statement &stmt, long batch_operations=1) |
| Execute the previously prepared query now and without creating result object. | |
| result | nanodbc::transact (statement &stmt, long batch_operations) |
| Execute the previously prepared query now. | |
| void | nanodbc::just_transact (statement &stmt, long batch_operations) |
| Execute the previously prepared query now and without creating result object. | |
| void | nanodbc::prepare (statement &stmt, string const &query, long timeout=0) |
| Prepares the given statement to execute on it associated connection. | |
Convenience functions.
| result nanodbc::execute | ( | connection & | conn, |
| string const & | query, | ||
| long | batch_operations = 1, |
||
| long | timeout = 0 |
||
| ) |
Immediately opens, prepares, and executes the given query directly on the given connection.
| conn | The connection where the statement will be executed. |
| query | The SQL query that will be executed. |
| batch_operations | Numbers of rows to fetch per rowset. |
| timeout | The number in seconds before query timeout. Default is 0 indicating no timeout. |
| void nanodbc::just_execute | ( | connection & | conn, |
| string const & | query, | ||
| long | batch_operations = 1, |
||
| long | timeout = 0 |
||
| ) |
Opens, prepares, and executes query directly without creating result object.
| conn | The connection where the statement will be executed. |
| query | The SQL query that will be executed. |
| batch_operations | Rows to fetch per rowset, or number of batch parameters to process. |
| timeout | The number in seconds before query timeout. Default is 0 indicating no timeout. |
| void nanodbc::bind_rows | ( | statement & | stmt, |
| Rows const & | rows, | ||
| Accessors const &... | accessors | ||
| ) |
Binds a range of rows, a parameter at a time.
Parameters are bound column-wise, which is what the ODBC drivers expect, from rows held however the caller finds convenient. Each accessor names one parameter, in the order the placeholders appear: either a pointer to a member, or anything callable with a row.
Where the library is built as C++17 or later, an accessor yielding std::optional binds an absent value as null.
The values are copied into the statement, so the rows are free to go out of scope before it is executed.
| stmt | The prepared statement to bind to. |
| rows | The rows to bind, a container with size() whose values the accessors read. |
| accessors | One per parameter marker, left to right. |
| database_error |
Execute the previously prepared query now.
| stmt | The prepared statement that will be executed. |
| batch_operations | Rows to fetch per rowset, or the number of batch parameters to process. |
| database_error |
| void nanodbc::just_execute | ( | statement & | stmt, |
| long | batch_operations = 1 |
||
| ) |
Execute the previously prepared query now and without creating result object.
| stmt | The prepared statement that will be executed. |
| batch_operations | Rows to fetch per rowset, or the number of batch parameters to process. |
| database_error |
Execute the previously prepared query now.
Executes within the context of a transaction object, commits directly after execution.
| stmt | The prepared statement that will be executed in batch. |
| batch_operations | Rows to fetch per rowset, or the number of batch parameters to process. |
| database_error |
| void nanodbc::just_transact | ( | statement & | stmt, |
| long | batch_operations | ||
| ) |
Execute the previously prepared query now and without creating result object.
Executes within the context of a transaction object, commits directly after execution.
| stmt | The prepared statement that will be executed in batch. |
| batch_operations | Rows to fetch per rowset, or the number of batch parameters to process. |
| database_error |
Prepares the given statement to execute on it associated connection.
If the statement is not open throws programming_error.
| stmt | The prepared statement that will be executed in batch. |
| query | The SQL query that will be executed. |
| timeout | The number in seconds before query timeout. Default is 0 indicating no timeout. |
| database_error | |
| programming_error |