forked from theoremoon/ShellgeiBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
database.go
36 lines (31 loc) · 876 Bytes
/
database.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
import (
"database/sql"
_ "github.com/mattn/go-sqlite3"
)
const schema = `
create table if not exists shellgeis (
user_id integer,
screen_name text,
tweet_id integer,
shellgei text,
result text default "",
error text default "",
timestamp integer
);
`
func insertResult(db *sql.DB, tweetID int64, result string, err error) error {
errStr := ""
if err != nil {
errStr = err.Error()
}
_, err2 := db.Exec("update shellgeis set result=?, error=? where tweet_id=?", result, errStr, tweetID)
return err2
}
func insertShellGei(db *sql.DB, userID int64, screenName string, tweetID int64, shellgei string, timestamp int64) error {
_, err := db.Exec("insert into shellgeis(user_id, screen_name, tweet_id, shellgei, timestamp) values (?,?,?,?,?)", userID, screenName, tweetID, shellgei, timestamp)
if err != nil {
return err
}
return nil
}