On Tuesday, October 9, 2012 11:32:18 AM UTC-7, Tassilo Horn wrote:
>
> Brian Craft <craft...@gmail.com <javascript:>> writes: 
>
> > How would I do an operation involving two databases? I'd need to call 
> > with-connection* from with-connection*? How would I then read from one 
> > & write to the other? 
>
> I've never used the jdbc lib, but essentially it should be something 
> along the lines of 
>
>   (let [db1 (connect-to-db1) 
>         db2 (connect-to-db2)] 
>     (with-connection* db2 
>       (write-stuff (with-connection* db1 (read-stuff))))) 
>
>
If (read-stuff) is not lazy, then this looks pretty simple: all the data is 
loaded in memory & returned to (write-stuff).  If the data is large you 
wouldn't want it all in memory. What then? Could you make read-stuff return 
a lazy sequence? My impression after a brief experiment is that this 
doesn't work: when the inner with-connection* returns, the db connection is 
closed. A lazy sequence from (read-stuff) then can't be evaluated w/o 
throwing an error.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to