diff --git a/client.go b/client.go index eabc318..859d147 100644 --- a/client.go +++ b/client.go @@ -39,6 +39,10 @@ func NewClient() (*Client, error) { return &Client{db: db}, nil } +func (client *Client) Test() error { + return client.db.Ping() +} + func (client *Client) recordQuery(query string) { client.history = append(client.history, query) } diff --git a/main.go b/main.go index 8cc8f19..6388c14 100644 --- a/main.go +++ b/main.go @@ -10,10 +10,10 @@ import ( var options struct { Url string `long:"url" description:"Database connection string"` - Host string `short:"h" long:"host" description:"Server hostname or IP" default:"localhost"` - Port int `short:"p" long:"port" description:"Server port" default:"5432"` - User string `short:"u" long:"user" description:"Database user" default:"postgres"` - DbName string `short:"d" long:"db" description:"Database name" default:"postgres"` + Host string `long:"host" description:"Server hostname or IP" default:"localhost"` + Port int `long:"port" description:"Server port" default:"5432"` + User string `long:"user" description:"Database user" default:"postgres"` + DbName string `long:"db" description:"Database name" default:"postgres"` Ssl string `long:"ssl" description:"SSL option" default:"disable"` Static string `short:"s" description:"Path to static assets" default:"./static"` } @@ -39,19 +39,18 @@ func getConnectionString() string { func initClient() { client, err := NewClient() - if err != nil { exitWithMessage(err.Error()) } - _, err = client.Query(SQL_INFO) - + fmt.Println("Connecting to server...") + err = client.Test() if err != nil { exitWithMessage(err.Error()) } + fmt.Println("Checking tables...") tables, err := client.Tables() - if err != nil { exitWithMessage(err.Error()) }