Skip to content
This repository was archived by the owner on May 6, 2026. It is now read-only.

Database

Nicuvëo edited this page Mar 24, 2014 · 5 revisions

Overview

A Database object is a wrapper around a raw sqlite3* pointer. The pointer is stored in a boost::shared_ptr, making Databases instances flyweight and copyable. When the last Database object owning a given sqlite3* pointer is deleted, the connection is closed.

Constructor

  • Database()

    Constructs an empty database object.

  • Database(const char* filename)

    Constructs a new database / opens an existing database.

Accessors

  • bool connected() const

    Answers whether the given instance is connected to a real database.
    database.connected() is equivalent to data.raw_data() != 0.

  • Statement make(const char* query) const

    Prepares a statement from the given query.

  • sqlite3* raw_data() const

    Access the underlying raw sqlite3* pointer. It is not meant to be stored, as its lifetime is managed via reference counting in the database type itself.

Mutators

  • void connect(const char* filename)

    Constructs a new database / opens an existing databse.

  • void disconnect()

    Disconnects the instance from its current database if any.

Execution

  • Rows exec(const char* query) const

Execute a query against the database and return the corresponding rows.

  • Rows exec(const char* query, const Parameters& params) const
  • void exec(const char* query, const RowCallback& callback) const
  • void exec(const char* query, const RowCallback& callback, const Parameters& params) const
  • RowRange result(const char* query) const
  • RowRange result(const char* query, const Parameters& params) const

Clone this wiki locally