Why not specify a :session so that data created by one block would remain available to subsequent blocks?

V.

On Thu, 7 Jul 2022 at 09:10, Naresh Gurbuxani <naresh_gurbuxani@hotmail.com> wrote:
I want to source some data from databases, then use this data in various blocks.  I am looking for the most efficient way to achieve this.  In below blocks, is the code in block ``connection'' executed thrice (economy of code but no saving of time) or is it only executed once then used twice?  If the code is run thrice, is there another way to create code blocks so that the code is executed only once?

Thanks,
Naresh

#+name: connection
#+begin_src R :exports results :results output
  ## my code here
#+end_src

#+begin_src R :exports results :results output graphics file :file figures/fig1.png
<<connection>>
## my code here
#+end_src

#+begin_src R :exports results output graphics file :file figures/fig2.png
<<connection>>
## my code here
#+end_src