Write different functions for source and target?
(declare source-conn)
(declare target-conn)
(defn get-source-data
[]
(sql/with-connection source-conn
...))
(defn put-target-data
[data]
(sql/with-connection target-conn
...))
(defn data-transfer
[]
(let [source (get-source-data)]
(put-target-data source)
...))
This approach may also save against concurrency issues just in case
(`binding` isolates on a ThreadLocal basis and isn't propagated across
threads.)
Regards,
Shantanu
On Jun 20, 5:48 pm, MattC <[email protected]> wrote:
> Hi,
>
> I am writing a lot of programs shuffling data between databases and
> would like to use Clojure for some of it.
>
> While investigating the sql contrib library I was wondering whether
> there is a supported way to have more than one database connection
> open at any one time.
>
> My initial approach was
>
> (use '[clojure.contrib.sql :as sql])
>
> (sql/with-connection {...}
> (let [source-connection (sql/connection)]
> (sql/with-connection {...}
> (let [target-connection (sql/connection)]
> (put-some-data (binding [sql/***** source-connection] (get-
> some-data))))
>
> well, roughly. but i am basically having a hard time switching
> between two open connections.
>
> is there a way ?
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en