Skip to content

Commit

Permalink
Use 'CREATE DATABASE IF NOT EXISTS' syntax
Browse files Browse the repository at this point in the history
closes #376
  • Loading branch information
gunnaraasen authored and sparrc committed Nov 18, 2015
1 parent 19e5d97 commit 03a6f28
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions outputs/influxdb/influxdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}

Expand Down

0 comments on commit 03a6f28

Please sign in to comment.