Пример #1
0
// CommitTransaction commits all changes made since StartTraction was called.
func (db *DB) CommitTransaction() error {
	_, err := db.dbConn.Exec("END")
	log.Debug(func() string {
		if err != nil {
			return "Error ending transaction"
		}
		return "Successfully ended transaction"
	}())
	return err
}
Пример #2
0
// RollbackTransaction aborts the transaction. No statement issued since
// StartTransaction was called will take effect.
func (db *DB) RollbackTransaction() error {
	_, err := db.dbConn.Exec("ROLLBACK")
	log.Debug(func() string {
		if err != nil {
			return "Error rolling back transaction"
		}
		return "Successfully rolled back transaction"
	}())
	return err
}
Пример #3
0
// StartTransaction starts an explicit transaction.
func (db *DB) StartTransaction() error {
	_, err := db.dbConn.Exec("BEGIN")
	log.Debug(func() string {
		if err != nil {
			return "Error starting transaction"
		}
		return "Successfully started transaction"
	}())
	return err
}
Пример #4
0
// Execute executes the given sqlite statement, of a type that doesn't return rows.
func (db *DB) Execute(stmt string) error {
	_, err := db.dbConn.Exec(stmt)
	log.Debug(func() string {
		if err != nil {
			return fmt.Sprintf("Error executing \"%s\", error: %s", stmt, err.Error())
		}
		return fmt.Sprintf("Successfully executed \"%s\"", stmt)
	}())

	return err
}