示例#1
0
文件: db.go 项目: slowfranklin/rqlite
// 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
文件: db.go 项目: slowfranklin/rqlite
// 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
文件: db.go 项目: slowfranklin/rqlite
// 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
文件: db.go 项目: slowfranklin/rqlite
// 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
}