boost_sqlite 1
A sqlite C++ library
Loading...
Searching...
No Matches
boost::sqlite::connection Struct Reference

main object for a connection to a database. More...

#include <include/boost/sqlite/connection.hpp>

Public Types

using handle_type = sqlite3*
 The handle of the connection.
 

Public Member Functions

 connection ()=default
 Default constructor.
 
 connection (connection &&)=default
 Move constructor.
 
 connection (cstring_ref filename, int flags=SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE)
 Construct a connection and connect it to filename.. flags is set by SQLITE_OPEN_* flags.
 
 connection (handle_type handle, bool take_ownership=true)
 Construct the connection from a handle.
 
handle_type handle () const
 Returns the handle.
 
bool has_column (cstring_ref table, cstring_ref column, cstring_ref db_name="main") const
 Check if the database has the table.
 
bool has_table (cstring_ref table, cstring_ref db_name="main") const
 Check if the database has the table.
 
connectionoperator= (connection &&)=default
 Move assign operator.
 
handle_type release () &&
 Release the owned handle.
 
bool valid () const
 Check if the database holds a valid handle.
 
void connect (cstring_ref filename, int flags=SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE)
 
void connect (cstring_ref filename, int flags, system::error_code &ec)
 
void close ()
 
void close (system::error_code &ec, error_info &ei)
 
resultset query (core::string_view q, system::error_code &ec, error_info &ei)
 
resultset query (core::string_view q)
 
template<typename T >
static_resultset< T > query (core::string_view q, system::error_code &ec, error_info &ei)
 
template<typename T >
static_resultset< T > query (core::string_view q)
 
void execute (cstring_ref q, system::error_code &ec, error_info &ei)
 
void execute (cstring_ref q)
 
template<typename StringLike , typename = decltype(std::declval<const StringLike&>().c_str())>
void execute (const StringLike &q, system::error_code &ec, error_info &ei)
 
template<typename StringLike , typename = decltype(std::declval<const StringLike&>().c_str())>
void execute (const StringLike &q)
 
statement prepare (core::string_view q, system::error_code &ec, error_info &ei)
 
statement prepare (core::string_view q)
 

Detailed Description

main object for a connection to a database.

Example
conn.connect("./my-database.db");
conn.prepare("insert into log (text) values ($1)").execute(std::make_tuple("booting up"));
main object for a connection to a database.
void connect(cstring_ref filename, int flags=SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE)

Definition at line 31 of file connection.hpp.

Constructor & Destructor Documentation

◆ connection()

boost::sqlite::connection::connection ( cstring_ref filename,
int flags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE )
inline

Construct a connection and connect it to filename.. flags is set by SQLITE_OPEN_* flags.

See also
https://www.sqlite.org/c3ref/c_open_autoproxy.html

Definition at line 50 of file connection.hpp.

Member Function Documentation

◆ close() [1/2]

void boost::sqlite::connection::close ( )

Close the database connection.

◆ close() [2/2]

void boost::sqlite::connection::close ( system::error_code & ec,
error_info & ei )

Close the database connection.

◆ connect() [1/2]

void boost::sqlite::connection::connect ( cstring_ref filename,
int flags,
system::error_code & ec )

Connect the database to filename. flags is set by SQLITE_OPEN_* flags.

◆ connect() [2/2]

void boost::sqlite::connection::connect ( cstring_ref filename,
int flags = SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE )

Connect the database to filename. flags is set by SQLITE_OPEN_* flags.

◆ execute() [1/4]

template<typename StringLike , typename = decltype(std::declval<const StringLike&>().c_str())>
void boost::sqlite::connection::execute ( const StringLike & q)
inline

Perform a query without parameters, executes multiple statements.

Definition at line 127 of file connection.hpp.

◆ execute() [2/4]

template<typename StringLike , typename = decltype(std::declval<const StringLike&>().c_str())>
void boost::sqlite::connection::execute ( const StringLike & q,
system::error_code & ec,
error_info & ei )
inline

Perform a query without parameters, executes multiple statements.

Definition at line 118 of file connection.hpp.

◆ execute() [3/4]

void boost::sqlite::connection::execute ( cstring_ref q)

Perform a query without parameters, executes multiple statements.

◆ execute() [4/4]

void boost::sqlite::connection::execute ( cstring_ref q,
system::error_code & ec,
error_info & ei )

Perform a query without parameters, executes multiple statements.

◆ prepare() [1/2]

statement boost::sqlite::connection::prepare ( core::string_view q)

Perform a query with parameters. Can only execute a single statement.

◆ prepare() [2/2]

statement boost::sqlite::connection::prepare ( core::string_view q,
system::error_code & ec,
error_info & ei )

Perform a query with parameters. Can only execute a single statement.

◆ query() [1/4]

resultset boost::sqlite::connection::query ( core::string_view q)

Perform a query without parameters. Can only execute a single statement.

◆ query() [2/4]

template<typename T >
static_resultset< T > boost::sqlite::connection::query ( core::string_view q)
inline

Perform a query without parameters. Can only execute a single statement.

Definition at line 96 of file connection.hpp.

◆ query() [3/4]

resultset boost::sqlite::connection::query ( core::string_view q,
system::error_code & ec,
error_info & ei )

Perform a query without parameters. Can only execute a single statement.

◆ query() [4/4]

template<typename T >
static_resultset< T > boost::sqlite::connection::query ( core::string_view q,
system::error_code & ec,
error_info & ei )
inline

Perform a query without parameters. Can only execute a single statement.

Definition at line 80 of file connection.hpp.


The documentation for this struct was generated from the following file: