|
|
|
@ -1,16 +1,16 @@
|
|
|
|
|
package seaweed
|
|
|
|
|
|
|
|
|
|
/***
|
|
|
|
|
Пакет seaweed предназначен для облегчения работы с БД sea
|
|
|
|
|
и weed.
|
|
|
|
|
Текущая версия: v1.0.6
|
|
|
|
|
Текущая версия: v1.0.7
|
|
|
|
|
***/
|
|
|
|
|
|
|
|
|
|
package seaweed
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"os"
|
|
|
|
|
"fmt"
|
|
|
|
|
"errors"
|
|
|
|
|
"flag"
|
|
|
|
|
"fmt"
|
|
|
|
|
"os"
|
|
|
|
|
|
|
|
|
|
_ "github.com/go-sql-driver/mysql"
|
|
|
|
|
"github.com/jmoiron/sqlx"
|
|
|
|
@ -24,22 +24,23 @@ var p = pio.NewTextPrinter("color", os.Stdout)
|
|
|
|
|
// ============= SEA ============
|
|
|
|
|
|
|
|
|
|
type Sea struct {
|
|
|
|
|
db *sqlx.DB
|
|
|
|
|
db *sqlx.DB
|
|
|
|
|
debug bool
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Connect to database and connect to weed
|
|
|
|
|
func Connect() (*Sea, error) {
|
|
|
|
|
debug := flag.Bool("debug", false, "enable debug mode")
|
|
|
|
|
fmt.Printf("debug: %v\n", *debug)
|
|
|
|
|
|
|
|
|
|
user := os.Getenv("SEA_USER")
|
|
|
|
|
if user == "" {
|
|
|
|
|
return nil, errors.New("Не установлена переменная SEA_USER")
|
|
|
|
|
return nil, errors.New("не установлена переменная SEA_USER")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
password := os.Getenv("SEA_PASSWORD")
|
|
|
|
|
if password == "" {
|
|
|
|
|
return nil, errors.New("Не установлена переменная SEA_PASSWORD")
|
|
|
|
|
return nil, errors.New("не установлена переменная SEA_PASSWORD")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
db, err := openDB(user, password)
|
|
|
|
@ -84,4 +85,3 @@ func (s *Sea) Albums() ([]Album, error) {
|
|
|
|
|
}
|
|
|
|
|
return albums, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|