SQLite for C++
Classes | Public Member Functions | Public Attributes | Private Attributes | List of all members
SQLite::Conn Class Reference

#include <sqlite_cpp.h>

Classes

class  PreparedStatement
 
class  ResultSet
 

Public Member Functions

 Conn (const char *db_name)
 
 Conn (const std::string db_name)
 
void exec (const std::string query)
 
Conn::PreparedStatement prepare (const std::string &stmt)
 
Conn::ResultSet query (const std::string &stmt)
 
void close () noexcept
 
sqlite3 * get_ptr ()
 

Public Attributes

std::shared_ptr< conn_basebase
 
char * error_message
 

Private Attributes

std::queue< PreparedStatement * > stmts
 

Detailed Description

Connection to a SQLite database

Constructor & Destructor Documentation

◆ Conn()

SQLite::Conn::Conn ( const char *  db_name)

Open a connection to a SQLite3 database

Parameters
[in]db_namePath to SQLite3 database

Member Function Documentation

◆ close()

void SQLite::Conn::close ( )
noexcept

Close the active database connection. If there are active prepared statements using this connection, they are also closed. Attempting to use the database or any associated statements after calling close() will throw an error.

In most cases, calling this method explicitly is not necessary because it gets called automatically when Conn goes out of scope.

Memory/Exception Safety

This method will never throw an exception. Calling close() after the first time will harmlessly do nothing.

◆ exec()

void SQLite::Conn::exec ( const std::string  query)

Execute a query that doesn't return anything

Parameters
[in]queryA SQL query

◆ get_ptr()

sqlite3 * SQLite::Conn::get_ptr ( )

Return a raw pointer to the sqlite3 handle.

Memory Safety

This function will never return invalid pointers. A runtime_error is thrown if this is used after Conn::close() has been called.

◆ prepare()

Conn::PreparedStatement SQLite::Conn::prepare ( const std::string &  stmt)

Prepare a query for execution

◆ query()

Conn::ResultSet SQLite::Conn::query ( const std::string &  stmt)

Return a query

Member Data Documentation

◆ base

std::shared_ptr<conn_base> SQLite::Conn::base
Initial value:
=
std::make_shared<conn_base>()

◆ error_message

char* SQLite::Conn::error_message

Database handle

◆ stmts

std::queue<PreparedStatement*> SQLite::Conn::stmts
private

Buffer for error messages


The documentation for this class was generated from the following files: