# The C++ Database Class

> The class Database should not be instantiated directly but is instead instantiated though one of its related classes; typically via the McoSqlEngine consturctor.

> ### For an overview see page C++ Classes

> The only Database method of interest is `beginTransaction()` which is typically called through an `McoSqlSession` object to share a single database connection between multiple threads:

>         McoSql::Transaction* beginTransaction(McoSql::Allocator* allocator,
>                                 McoSql::Transaction::Mode mode,
>                                 int priority,
>                                 McoSql::Transaction::IsolationLevel level,
>                                 bool nolock = false);

> ### Example

>         McoMultithreadedSqlEngine engine;
>         ...

>         McoSqlSession session(&engine);
>         Transaction* trans = session->database()->beginTransaction(Transaction::ReadWrite);
>         session->executeStatement(trans, "update Member set balance=%i where id=%i",
>                         fromBalance, idFrom);
>         session->executeStatement(trans, "update Member set balance=%i where id=%i",
>                         toBalance, idTo);
>         trans->commit();
>         trans->release();