Passing variables between jython scripts and sharing SQL connection
<p>I have two jython scripts and I have created connection to Oracle database in the 1st script and declared some variables and I want to use that in 2nd script without having to write the getconnection string again in 2nd script and also have to use the data / variables from one script and pass it on to the other.
Global keyword is not working.
Thanks in advance .</p>

<p>If all you want is sharing some common values e.g. target server name , you can </p>

<p>1) create a new .py file which contains the variable</p>

<pre><code># common.py
DB=db.company.com
</code></pre>

<p>2) In your scripts, import the variable from the new .py file</p>

<pre><code>from common import DB

...

odbc.connect('SERVER=%s' % DB)
</code></pre>

<p>These code assumes you put all .py files in the same directory.</p>

python sql jython