Use 'CREATE DATABASE IF NOT EXISTS' syntax

closes #376
This commit is contained in:
gunnaraasen
2015-11-18 00:41:25 -07:00
committed by Cameron Sparr
parent 19e5d975ca
commit 03a6f28d55
+2 -2
View File
@@ -97,10 +97,10 @@ func (i *InfluxDB) Connect() error {
// Create Database if it doesn't exist
_, e := c.Query(client.Query{
Command: fmt.Sprintf("CREATE DATABASE %s", i.Database),
Command: fmt.Sprintf("CREATE DATABASE IF NOT EXISTS %s", i.Database),
})
if e != nil && !strings.Contains(e.Error(), "database already exists") {
if e != nil {
log.Println("Database creation failed: " + e.Error())
}