|
@@ -17,6 +17,7 @@ func (db *DBData) Open(filename string) {
|
|
|
if err != nil {
|
|
|
log.Panicln("Error Opening Sqlite3:", err)
|
|
|
}
|
|
|
+ db.Create()
|
|
|
}
|
|
|
|
|
|
func (db *DBData) Close() {
|
|
@@ -43,22 +44,14 @@ func (db *DBData) Create() {
|
|
|
}
|
|
|
|
|
|
func (db *DBData) GetSetting(setting string, ifMissing string) string {
|
|
|
- rows, err := db.DB.Query("SELECT value FROM settings WHERE username=? AND setting=?;", db.User, setting)
|
|
|
+ row := db.DB.QueryRow("SELECT value FROM settings WHERE username=? AND setting=?;", db.User, setting)
|
|
|
+ var value string
|
|
|
+ log.Printf("row: %#v\n", row)
|
|
|
+ err := row.Scan(&value)
|
|
|
if err != nil {
|
|
|
- log.Panicln("Query GetSetting", err)
|
|
|
+ return ifMissing
|
|
|
}
|
|
|
- defer rows.Close()
|
|
|
- for rows.Next() {
|
|
|
- var value string
|
|
|
- err = rows.Scan(&value)
|
|
|
- if err != nil {
|
|
|
- log.Panicln("Scan GetSetting", err)
|
|
|
- }
|
|
|
- // log.Printf("GetSetting %s %s : %s\n", db.User, setting, value)
|
|
|
- return value
|
|
|
- }
|
|
|
- // log.Printf("GetSetting %s %s :(", db.User, setting)
|
|
|
- return ifMissing
|
|
|
+ return value
|
|
|
}
|
|
|
|
|
|
func (db *DBData) SetSetting(setting string, value string) {
|