2019-02-07 10:21:19 +03:00
|
|
|
package sqlite
|
|
|
|
|
|
|
|
func (db *Sqlite3Accessor) GetSetting(key string, defaultvalue string) (string, error) {
|
2019-02-08 18:02:24 +03:00
|
|
|
rows, err := db.db.Query(getSettingQuery, key)
|
2019-02-07 10:21:19 +03:00
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
|
|
|
|
defer rows.Close()
|
|
|
|
|
2019-02-08 18:02:24 +03:00
|
|
|
value := defaultvalue
|
2019-02-07 10:21:19 +03:00
|
|
|
|
|
|
|
if rows.Next() {
|
|
|
|
|
|
|
|
err = rows.Scan(&value)
|
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return value, nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (db *Sqlite3Accessor) SetSetting(key string, value string) error {
|
2019-02-08 18:02:24 +03:00
|
|
|
_, err := db.db.Exec(setSettingQuery, key, value)
|
2019-02-07 10:21:19 +03:00
|
|
|
return err
|
|
|
|
}
|