diff --git a/src/metabase/db.clj b/src/metabase/db.clj
index 015bf395725f6c9d00c78e521c56240484356fff..784fb9dc4bce749bc431b1b5a8e25a5ba4dbd412 100644
--- a/src/metabase/db.clj
+++ b/src/metabase/db.clj
@@ -43,7 +43,7 @@
 (defn parse-connection-string
   "Parse a DB connection URI like `postgres://cam@localhost.com:5432/cams_cool_db?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory` and return a broken-out map."
   [uri]
-  (when-let [[_ protocol user pass host port db query] (re-matches #"^([^:/@]+)://([^:/@]+)(?::([^:@]+))?@([^:@]+)(?::(\d+))?/([^/?]+)(?:\?(.*))?$" uri)]
+  (when-let [[_ protocol user pass host port db query] (re-matches #"^([^:/@]+)://(?:([^:/@]+)(?::([^:@]+))?@)?([^:@]+)(?::(\d+))?/([^/?]+)(?:\?(.*))?$" uri)]
     (merge {:type     (keyword protocol)
             :user     user
             :password pass
diff --git a/test/metabase/db_test.clj b/test/metabase/db_test.clj
new file mode 100644
index 0000000000000000000000000000000000000000..85da3ad3a86cd28f9e42aa146ca2aec545ff544b
--- /dev/null
+++ b/test/metabase/db_test.clj
@@ -0,0 +1,11 @@
+(ns metabase.db-test
+  (:require [expectations :refer :all]
+            [metabase.db :as db]))
+
+;; parse minimal connection string
+(expect {:type :postgres :user nil :password nil :host "localhost" :port nil :dbname "toms_cool_db" }
+  (db/parse-connection-string "postgres://localhost/toms_cool_db"))
+
+;; parse all fields and query string arguments
+(expect {:type :postgres :user "tom" :password "1234" :host "localhost" :port "5432" :dbname "toms_cool_db" :ssl "true" :sslfactory "org.postgresql.ssl.NonValidatingFactory"}
+  (db/parse-connection-string "postgres://tom:1234@localhost:5432/toms_cool_db?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory"))