Package obitools :: Package obischemas
[hide private]
[frames] | no frames]

Source Code for Package obitools.obischemas

 1  from obitools.obischemas import kb 
 2  __connection__ = None 
 3   
4 -def initConnection(options):
5 global __connection__ 6 param = {} 7 if hasattr(options, "dbname") and options.dbname is not None: 8 param["database"]=options.dbname 9 if hasattr(options, "dbhost") and options.dbhost is not None: 10 param["host"]=options.dbhost 11 if hasattr(options, "dbuser") and options.dbuser is not None: 12 param["username"]=options.dbuser 13 if hasattr(options, "dbpassword") and options.dbpassword is not None: 14 param["password"]=options.dbpassword 15 16 __connection__=kb.getConnection(**param) 17 __connection__.autocommit=options.autocommit
18
19 -def getConnection(options=None):
20 global __connection__ 21 22 if options is not None: 23 initConnection(options) 24 25 assert __connection__ is not None,"database connection is not initialized" 26 27 return __connection__
28