whats the best way to go about this in python? I have a number of like so
def test1()
.... code .....
def test2()
.... code .....
def test3()
.... code .....
how could I create one database connection and use it across all the functions? I'm connecting to my database in a test file like so:
import MySQLdb as mdb
import sys
try:
con = mdb.connect('10.243.17.13', 'mark', 'LiverpoolFc', 'dex');
cur = con.cursor()
cur.execute("SELECT VERSION()")
ver = cur.fetchone()
print "Database version : %s " % ver
except mdb.Error, e:
print "Error %d: %s" % (e.args[0],e.args[1])
sys.exit(1)