Start a multi-statement transaction.

        Takes the same arguments as :class:`TransactionOptions`.

        .. versionadded:: 3.7
175051
def start_transaction(self, read_concern=None, write_concern=None,
                          read_preference=None):
        
        self._check_ended()

        if self._in_transaction:
            raise InvalidOperation("Transaction already in progress")

        read_concern = self._inherit_option("read_concern", read_concern)
        write_concern = self._inherit_option("write_concern", write_concern)
        read_preference = self._inherit_option(
            "read_preference", read_preference)

        self._transaction.opts = TransactionOptions(
            read_concern, write_concern, read_preference)
        self._transaction.reset()
        self._transaction.state = _TxnState.STARTING
        self._start_retryable_write()
        return _TransactionContext(self)
908788
private function OpenTransaction(){
        if(!$this->transactionActive) {
            $this->beginTransaction();
            $this->exec("SET FOREIGN_KEY_CHECKS = 0;");
            $this->transactionActive = true;
        }
    }
932287
def execute( self, conn, daoinput, transaction = False ):
        
        binds = {} 
        bindlist=[]
        
        if isinstance(daoinput, dict) and "block_name" in daoinput.keys():
            binds = {"block_name": daoinput["block_name"]}
            r = self.dbi.processData(self.sql_sel, binds, conn, False)
            bfile = self.format(r)
            bfile_list = []
            for f in bfile:
                bfile_list.append(f[0])           
            if "child_parent_id_list" in daoinput.keys():
                files = []
                for i in daoinput["child_parent_id_list"]:
                    files.append(i[0])
                if set(files)-set(bfile_list):
                    dbsExceptionHandler('dbsException-invalid-input2', "Files required in the same block for FileParent/insert2 dao.", self.logger.exception) 
            else:
                dbsExceptionHandler('dbsException-invalid-input2', "child_parent_id_list required for FileParent/insert2 dao.", self.logger.exception) 
        else:
            dbsExceptionHandler('dbsException-invalid-input2', "Block_name required in the same block for FileParent/insert2 dao.", self.logger.exception)
        binds = {} 
        for pf in daoinput["child_parent_id_list"]:
            binds = {"this_file_id":pf[0], "parent_file_id": pf[1]}
            bindlist.append(binds) 
        self.dbi.processData(self.sql, bindlist, conn, transaction)
948126
public static void commitTransaction() {
        Connection connection = tl_conn.get();
        if (connection == null) {
            throw new RuntimeException("You do not start a Transaction so you can not commit a transaction!");
        }
        try {
            connection.commit();
            connection.close();
            tl_conn.remove();
            tl_sp.remove();
        } catch (SQLException e) {
            JDBCUtils.rollbackTransaction();
            throw new RuntimeException(e);
        }
    }
10076
@Nonnull
  public static TransactionOptions create(int numberOfAttempts) {
    Preconditions.checkArgument(numberOfAttempts > 0, "You must allow at least one attempt");
    return new TransactionOptions(numberOfAttempts, null, null);
  }
73224
@Override
    public void begin()
    {
        if (isActive())
        {
            throw new IllegalStateException("Transaction is already active");
        }
        else
        {
            this.coordinator = ((EntityManagerImpl) entityManager).getPersistenceDelegator().getCoordinator();
            ((EntityManagerImpl) entityManager).getPersistenceDelegator().begin(); // transaction
                                                                                   // de-marcation.
            this.coordinator.coordinate(TxAction.BEGIN);
        }
    }
1040105
def _execute_transactions(self, address):
        
        for i in range(self.transaction_count):
            self.time = datetime.now()
            log.info(
                "Starting message call transaction, iteration: {}, {} initial states".format(
                    i, len(self.open_states)
                )
            )
            for hook in self._start_sym_trans_hooks:
                hook()

            execute_message_call(self, address)

            for hook in self._stop_sym_trans_hooks:
                hook()
1109701
public void execute(Runnable statements)
	{
		try (HibernateTransaction tx = start().withAutoRollback())
		{
			statements.run();

			// Success, perform a TX commit
			tx.commit();
		}
	}
1240011
public void doBegin(Object transaction, TransactionDefinition definition) throws TransactionException {
		try {
			CompensatingTransactionObject txObject = (CompensatingTransactionObject) transaction;
			if (txObject.getHolder() == null) {
				CompensatingTransactionHolderSupport contextHolder = getNewHolder();
				txObject.setHolder(contextHolder);

				TransactionSynchronizationManager.bindResource(getTransactionSynchronizationKey(), contextHolder);
			}
		}
		catch (Exception e) {
			throw new CannotCreateTransactionException("Could not create DirContext instance for transaction", e);
		}
	}
1260651
def perform_ops(self):
        
        with self.db:
            with closing(self.db.cursor()) as cursor:
                cursor.execute('BEGIN TRANSACTION')
                self._perform_ops(cursor)
169847
public void commit(TransactionStatus status) throws TransactionException {

		MultiTransactionStatus multiTransactionStatus = (MultiTransactionStatus) status;

		boolean commit = true;
		Exception commitException = null;
		PlatformTransactionManager commitExceptionTransactionManager = null;

		for (PlatformTransactionManager transactionManager : reverse(transactionManagers)) {

			if (commit) {

				try {
					multiTransactionStatus.commit(transactionManager);
				} catch (Exception ex) {
					commit = false;
					commitException = ex;
					commitExceptionTransactionManager = transactionManager;
				}

			} else {

				// after unsucessfull commit we must try to rollback remaining transaction managers

				try {
					multiTransactionStatus.rollback(transactionManager);
				} catch (Exception ex) {
					LOGGER.warn("Rollback exception (after commit) (" + transactionManager + ") " + ex.getMessage(), ex);
				}
			}
		}

		if (multiTransactionStatus.isNewSynchronization()) {
			synchronizationManager.clearSynchronization();
		}

		if (commitException != null) {
			boolean firstTransactionManagerFailed = commitExceptionTransactionManager == getLastTransactionManager();
			int transactionState = firstTransactionManagerFailed ? HeuristicCompletionException.STATE_ROLLED_BACK
					: HeuristicCompletionException.STATE_MIXED;
			throw new HeuristicCompletionException(transactionState, commitException);
		}
	}
986963
public void startTransaction()
   {
      Long key = Long.valueOf(Thread.currentThread().getId());
      TransactionImpl tx = txs.get(key);

      if (tx == null)
      {
         TransactionImpl newTx = new TransactionImpl(key);
         tx = txs.putIfAbsent(key, newTx);
         if (tx == null)
            tx = newTx;
      }

      tx.active();
   }
425981
public function transactionStart()
    {
        if (empty($this->oDb)) {
            $this->connect();
        }

        try {

            $this->oDb->beginTransaction();
            $this->transactionRunning = true;

            return true;

        } catch (\Exception $e) {
            throw new TransactionException($e->getMessage(), $e->getCode());
        }
    }
1364478
def maybe_transactional(func):
    
    @wraps(func)
    def wrapper(*args, **kwargs):
        commit = kwargs.get("commit", True)
        with transaction(commit=commit):
            return func(*args, **kwargs)
    return wrapper
371097
public function begin() {
        if($this->isInTransaction()) {
            throw new \Exception('You cannot start a new transaction once you are already in one (Originally started at: ' . self::$stackTrace . ')');
        } else {
            $e = new \Exception();
            self::$stackTrace = $e->getTraceAsString();
        }
        $transactionManager = new TransactionManager();
        $transactionManager->setDbService($this->getDbService());
        $this->setTransaction($transactionManager->get());
    }
643301
def start_txn(self, txn_name=None):

		'''
		
		'''

		# if no name provided, create one
		if not txn_name:
			txn_name = uuid.uuid4().hex

		# request new transaction
		txn_response = self.api.http_request('POST','%s/fcr:tx' % self.root, data=None, headers=None)

		# if 201, transaction was created
		if txn_response.status_code == 201:

			txn_uri = txn_response.headers['Location']
			logger.debug("spawning transaction: %s" % txn_uri)

			# init new Transaction, and pass Expires header
			txn = Transaction(
				self, # pass the repository
				txn_name,
				txn_uri,
				expires = txn_response.headers['Expires'])

			# append to self
			self.txns[txn_name] = txn

			# return
			return txn
1309114
def _ExecuteTransaction(self, transaction):
    """"""

    def Action(connection):
      connection.cursor.execute("START TRANSACTION")
      for query in transaction:
        connection.cursor.execute(query["query"], query["args"])
      connection.cursor.execute("COMMIT")
      return connection.cursor.fetchall()

    return self._RetryWrapper(Action)