VSQLite++ 0.3
Loading...
Searching...
No Matches
sqlite::v2::connection Struct Reference

connection is used to open, close, attach and detach a database. Further it has to be passed to all classes since it represents the connection to the database and contains the internal needed handle, so you can see a connection object as handle to the database An object of this class is not copyable More...

#include <connection.hpp>

Collaboration diagram for sqlite::v2::connection:
Collaboration graph

Public Member Functions

 connection (std::string const &db)
 constructor opens the database
 connection (std::string const &db, filesystem_adapter_ptr fs)
 connection (connection const &)=delete
connectionoperator= (connection const &)=delete
 connection (std::string const &db, sqlite::open_mode open_mode)
 constructor opens the database
 connection (std::string const &db, sqlite::open_mode open_mode, filesystem_adapter_ptr fs)
 ~connection ()
 destructor closes the database automatically
void attach (std::string const &db, std::string const &database_alias)
 attaches another database file to the database represented by the object of this class. It is possible to attach up to 10 times the same database file with different aliases
void detach (std::string const &database_alias)
 detaches a database via alias, if the same database was attached with several names they will be still present
std::int64_t get_last_insert_rowid ()
 Returns the last inserted rowid in the currently opened database.
void configure_statement_cache (statement_cache_config const &cfg)
statement_cache_config statement_cache_settings () const
void clear_statement_cache ()

Private Member Functions

void open (std::string const &db)
void open (std::string const &db, bool readonly)
void open (std::string const &db, sqlite::open_mode open_mode)
void close ()
void access_check ()
void open_with_flags (std::string const &db, int flags)
sqlite3_stmt * acquire_cached_statement (std::string const &sql)
void release_cached_statement (std::string const &sql, sqlite3_stmt *stmt)

Private Attributes

sqlite3 * handle
filesystem_adapter_ptr filesystem
statement_cache cache_

Friends

struct private_accessor

Detailed Description

connection is used to open, close, attach and detach a database. Further it has to be passed to all classes since it represents the connection to the database and contains the internal needed handle, so you can see a connection object as handle to the database An object of this class is not copyable

Definition at line 64 of file connection.hpp.

Constructor & Destructor Documentation

◆ connection() [1/5]

sqlite::v2::connection::connection ( std::string const & db)

constructor opens the database

Parameters
dbfilename of the database file if the given file already exists the file will be opened as database. If the file does not exist a new database will be created

Referenced by connection(), and operator=().

◆ connection() [2/5]

sqlite::v2::connection::connection ( std::string const & db,
filesystem_adapter_ptr fs )

◆ connection() [3/5]

sqlite::v2::connection::connection ( connection const & )
delete

References connection().

Here is the call graph for this function:

◆ connection() [4/5]

sqlite::v2::connection::connection ( std::string const & db,
sqlite::open_mode open_mode )

constructor opens the database

Parameters
dbfilename of the database file
open_modeHow to behave when opening the database
Remarks
If open_mode::always_create is specified and the file exists but cannot be removed, this will throw a database_system_error exception with the system error code causing the failure.

If the database does not exist and open_mode::open_existing was specified, a database_exception will be thrown.

◆ connection() [5/5]

sqlite::v2::connection::connection ( std::string const & db,
sqlite::open_mode open_mode,
filesystem_adapter_ptr fs )

◆ ~connection()

sqlite::v2::connection::~connection ( )

destructor closes the database automatically

Member Function Documentation

◆ access_check()

void sqlite::v2::connection::access_check ( )
private

◆ acquire_cached_statement()

sqlite3_stmt * sqlite::v2::connection::acquire_cached_statement ( std::string const & sql)
private

◆ attach()

void sqlite::v2::connection::attach ( std::string const & db,
std::string const & database_alias )

attaches another database file to the database represented by the object of this class. It is possible to attach up to 10 times the same database file with different aliases

Parameters
dbdatabase filename of the database should be attached
database_aliasalias which should be used

◆ clear_statement_cache()

void sqlite::v2::connection::clear_statement_cache ( )

◆ close()

void sqlite::v2::connection::close ( )
private

◆ configure_statement_cache()

void sqlite::v2::connection::configure_statement_cache ( statement_cache_config const & cfg)

◆ detach()

void sqlite::v2::connection::detach ( std::string const & database_alias)

detaches a database via alias, if the same database was attached with several names they will be still present

Parameters
database_aliasof the database (must be the same alias which was passed in the attach() call)

◆ get_last_insert_rowid()

std::int64_t sqlite::v2::connection::get_last_insert_rowid ( )

Returns the last inserted rowid in the currently opened database.

◆ open() [1/3]

void sqlite::v2::connection::open ( std::string const & db)
private

◆ open() [2/3]

void sqlite::v2::connection::open ( std::string const & db,
bool readonly )
private

◆ open() [3/3]

void sqlite::v2::connection::open ( std::string const & db,
sqlite::open_mode open_mode )
private

◆ open_with_flags()

void sqlite::v2::connection::open_with_flags ( std::string const & db,
int flags )
private

◆ operator=()

connection & sqlite::v2::connection::operator= ( connection const & )
delete

References connection().

Here is the call graph for this function:

◆ release_cached_statement()

void sqlite::v2::connection::release_cached_statement ( std::string const & sql,
sqlite3_stmt * stmt )
private

◆ statement_cache_settings()

statement_cache_config sqlite::v2::connection::statement_cache_settings ( ) const

◆ private_accessor

friend struct private_accessor
friend

Definition at line 122 of file connection.hpp.

References private_accessor.

Referenced by private_accessor.

Member Data Documentation

◆ cache_

statement_cache sqlite::v2::connection::cache_
private

Definition at line 137 of file connection.hpp.

◆ filesystem

filesystem_adapter_ptr sqlite::v2::connection::filesystem
private

Definition at line 136 of file connection.hpp.

◆ handle

sqlite3* sqlite::v2::connection::handle
private

Definition at line 135 of file connection.hpp.

Referenced by sqlite::v2::private_accessor::get_handle().


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