# Class transaction

- Defined in File cql.hpp

## Class Documentation

class transaction

  Transaction class. At construction, this class starts a transaction on the connection and at exit an automatic rollback is done, unless commit was called.

  Public Functions

  transaction(connection &conn)

    Constructor.

  result exec(std::string query)

    Execute the sql in query returning an iterable result.

  result exec(std::string query, std::string &tail)

    Execute the sql in query returning an iterable result. Updates tail with what remains after the first statement in query.

  template<typename ...Ts>
  inline cql_iterator_proxy<Ts...> stream(const std::string &sql)

    Execute the sql in sql and return the result as a stream.

  void commit()

    Commit the result of the operations.

  void rollback()

    Rollback the result of the operations, the underlying data is restored to the state before the construction of this transaction.