0

I want to create a transaction in go and while doing that I get error : near "SET": syntax error. The code:

db.Exec("SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;")
if err := db.Exec("SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED").Error; err != nil {
    return err
}

tx:=db.Begin()

Even when omitting ";" I get the same error. I'm using sqlite3 database and gorm ORM.

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189

1 Answers1

0

To achieve this in SQLite you have to use pragmas.

Does this work?

if err := db.Exec("PRAGMA read_uncommitted = true").Error; err != nil {
    return err
}

tx:=db.Begin()
torkel
  • 2,096
  • 3
  • 10
  • 20