    - `:port`           ClickHouse Server Port (default: 8123)
    - `:database`       ClickHouse Database Name (default: \"default\")
    - `:table`          ClickHouse Table Name (default: \"riemann\")
+   - `:username`       ClickHouse User Name (default: \"default\")
+   - `:password`       ClickHouse Password (default: \"\")
 
-   You need to first create a clickhouse table:
+   It will create the clickhouse table using the following query:
 
-   CREATE TABLE default.riemann
+   CREATE TABLE IF NOT EXISTS default.riemann
    (
       `timestamp` DateTime,
       `host` String,

  (let [processed-events (map generate-datapoint events)]
    (str/join "" processed-events)))

(defn generate-url
  "Generates the URL to which datapoint should be posted."
  [opts]
  (let [scheme   (:scheme opts)
        host     (:host opts)
        port     (:port opts)
        database (:database opts)
        table    (:table opts)]
    (str scheme host ":" port "/?query=INSERT%20INTO%20" database "." table "%20FORMAT%20CSV")))

(defn post-datapoint
  "Post the riemann event as clickhouse datapoint."

                     :host "localhost"
                     :port 8123
                     :database "default"
                     :table "riemann"
                     :username "default"
                     :password ""}
                    opts)
        _ (post-datapoint (generate-create-url opts) (generate-create-query opts))]
    (fn [events]
      (let [insert-url (generate-insert-url opts)
            datapoint (generate-datapoint-batch events)]
        (if-not (nil? datapoint)
          (post-datapoint insert-url datapoint))))))