diff --git a/.gitignore b/.gitignore index e01cfd7..764dec8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ tags config.ini gitea-matrix-bot +tokens.db diff --git a/giteadb.go b/giteadb.go index 2081162..b15666a 100644 --- a/giteadb.go +++ b/giteadb.go @@ -50,7 +50,7 @@ func (dbg *GiteaDB) GetToken(room string) string { } defer db.Close() - stmt, err := db.Prepare("select name from foo where id = ?") + stmt, err := db.Prepare("select token from tokens where room = ?") if err != nil { log.Fatal(err) } @@ -134,17 +134,20 @@ func (dbg *GiteaDB) Set(room, token string) { if err != nil { log.Fatal(err) } + fmt.Println("inserting") + stmt, err := tx.Prepare("insert into tokens(room, token) values(?, ?)") if err != nil { log.Fatal(err) } + defer stmt.Close() - for i := 0; i < 100; i++ { - _, err = stmt.Exec(room, token) - if err != nil { - log.Fatal(err) - } + _, err = stmt.Exec(room, token) + if err != nil { + log.Fatal(err) } tx.Commit() + dbg.GetAll() + }