28 lines
401 B
Go
28 lines
401 B
Go
package common
|
|
|
|
import (
|
|
"log"
|
|
"time"
|
|
|
|
"github.com/Xe/gorqlite"
|
|
)
|
|
|
|
func RQLiteConnect(u string) (gorqlite.Connection, error) {
|
|
var (
|
|
db gorqlite.Connection
|
|
err error
|
|
)
|
|
|
|
for i := 0; i < 5; i++ {
|
|
db, err = gorqlite.Open(u)
|
|
if err == nil {
|
|
break
|
|
}
|
|
log.Printf("sleeping 1 second to try again, got error connecting to %s: %v", u, err)
|
|
|
|
time.Sleep(time.Second)
|
|
}
|
|
|
|
return db, err
|
|
}
|