commit 3347c43055556f7c81ba862eb1c693f22fc74d10 Author: Nicolas Duhamel Date: Fri Feb 5 21:32:06 2016 +0100 First commit diff --git a/run.go b/run.go new file mode 100644 index 0000000..303fba7 --- /dev/null +++ b/run.go @@ -0,0 +1,35 @@ +package main + +import ( + "flag" + + "github.com/jmoiron/sqlx" + "github.com/kr/pretty" + _ "github.com/lib/pq" +) + +var pg string +var sqlFile string + +func init() { + flag.StringVar(&pg, "pg", "", "postgres database's connection string") + flag.StringVar(&sqlFile, "file", "", "path to a sql file") +} + +func main() { + flag.Parse() + + db := sqlx.MustConnect("postgres", pg) + err := db.Ping() + if err != nil { + pretty.Println(err) + } + + if sqlFile != "" { + r, err := sqlx.LoadFile(db, sqlFile) + if err != nil { + pretty.Println(err) + } + pretty.Println(r) + } +}