how are people here managing database connections in their clerk notebooks (esp during development)
I used Clerk with Playwright (the https://playwright.dev/java/) a few months ago, tried a few things.
In the end, I was the most happy with a defonce’d connection, and an out-commented “close and reconnect” alter-var-root right below it.
(defonce conn (playwright ,,,))
#_(alter-var-root #'conn (fn [conn] (.close conn) (playwright ,,,)))
I used the alter-var-root untill I had the thing I wanted in conn, then mostly didn’t touch it after.
Other (discarded) approaches felt more heavyweight than useful—especially those who required manual work before the Clerk document “worked”. Also tried a normal def, which caused problems—I had two running instances, when I just wanted one.
(I realize that a Playwright instance isn’t the same as database connection, but I’d do the same thing with a PostgreSQL connection).I hope you share back what you end up with, I’m curious!
More details about my process in a previous thread: https://clojurians.slack.com/archives/C035GRLJEP8/p1705855285929259