From 03a6f28d55db4ee3eec651eb09ce3b856cf4eb88 Mon Sep 17 00:00:00 2001 From: gunnaraasen Date: Mon, 16 Nov 2015 15:55:49 -0800 Subject: [PATCH] Use 'CREATE DATABASE IF NOT EXISTS' syntax closes #376 --- outputs/influxdb/influxdb.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/outputs/influxdb/influxdb.go b/outputs/influxdb/influxdb.go index 983fcc6ee987c..7d3f95d1e5d2e 100644 --- a/outputs/influxdb/influxdb.go +++ b/outputs/influxdb/influxdb.go @@ -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()) }