Sqlite database connection.
More...
#include <sqlite.hpp>
Sqlite database connection.
Holds a connection to a database. SQL may be run with either the exec() method, or by using create_statement() to build a Connection::Stmt object
- See also
- C API
◆ Connection()
sqlite::Connection::Connection |
( |
const std::string & |
filename | ) |
|
|
explicit |
Open / create new DB.
- Parameters
-
[in] | filename | Path to sqlite database file |
- Exceptions
-
- See also
- C API
◆ create_statement()
Connection::Stmt sqlite::Connection::create_statement |
( |
const std::string & |
sql | ) |
|
Create a new prepared statement.
- Parameters
-
[in] | sql | SQL code to prepare |
- Returns
- Prepared statement for the SQL code input
- Exceptions
-
- See also
- C API
◆ exec()
void sqlite::Connection::exec |
( |
const std::string & |
sql, |
|
|
int(*)(void *, int, char **, char **) |
callback = nullptr , |
|
|
void * |
arg = nullptr |
|
) |
| |
Execute SQL statement(s)
Will execute the SQL in-place, without needing to create a Connection::Stmt object.
- Parameters
-
[in] | sql | SQL code to execute |
[in] | callback | Function to call for every row. May be NULL. Parameters are:
- arg: The arg parameter from the exec call
- column_data: Array of column data (as strings) for the current row
- column_names: Array of column names
|
[in,out] | arg | Data to pass as 1st arg of callback. May be NULL. |
- Exceptions
-
- See also
- C API
◆ begin_transaction()
void sqlite::Connection::begin_transaction |
( |
| ) |
|
Start a transaction.
- See also
- C API
◆ commit()
void sqlite::Connection::commit |
( |
| ) |
|
End a transaction & commit.
- See also
- C API
◆ rollback()
void sqlite::Connection::rollback |
( |
| ) |
|
End a transaction & rollback.
- See also
- C API
◆ interrupt()
void sqlite::Connection::interrupt |
( |
| ) |
|
Interrupt a long-running query.
- See also
- C API
◆ last_insert_rowid()
sqlite3_int64 sqlite::Connection::last_insert_rowid |
( |
| ) |
|
Get last INSERTed Row ID.
@ returns Row ID for last INSERTed row
- See also
- C API
◆ total_changes()
int sqlite::Connection::total_changes |
( |
| ) |
|
Get total number of rows modified.
- Returns
- Total number of rows inserted, modified or deleted by all INSERT, UPDATE or DELETE statements completed since the database connection was opened, including those executed as part of trigger programs.
- See also
- C API
◆ table_column_metadata()
Connection::Column_metadata sqlite::Connection::table_column_metadata |
( |
const std::string & |
table_name, |
|
|
const std::string & |
column_name, |
|
|
const std::string & |
db_name = "main" |
|
) |
| |
Get column metadata.
- Parameters
-
[in] | table_name | Table name |
[in] | column_name | Column name |
[in] | db_name | DB name, or "main" if omitted |
- Returns
- The chosen column's metadata
- Exceptions
-
- See also
- C API
◆ get_c_obj() [1/2]
const sqlite3 * sqlite::Connection::get_c_obj |
( |
| ) |
const |
Get wrapped C sqlite3 object (for use with the sqlite C API)
- Returns
- C sqlite3 object
◆ get_c_obj() [2/2]
sqlite3 * sqlite::Connection::get_c_obj |
( |
| ) |
|
Get wrapped C sqlite3 object (for use with the sqlite C API)
- Returns
- C sqlite3 object
The documentation for this class was generated from the following files: