def real_getRW(key="default"): global g_dbh_pool if g_dbh_pool.get(key, None) is None: import MySQLdb g_dbh_pool[key] = Pool.Pool( Pool.Constructor(MySQLdb.connect, **getConnectInfo(key)), getConnectInfo(key).get("connections", 30)) return g_dbh_pool[key].get()
print e sys.exit(0) except ConfigParser.NoSectionError: print "Error: Missing [database] section in config files." sys.exit(0) except ConfigParser.NoOptionError: print "Error: Missing vital option in configs." sys.exit(0) type = "mysql" ctor = Pool.Constructor(MySQLdb.connect, host=dbhostname, port=dbport, user=dbuser, db=dbname, passwd=dbpass, read_default_file="~/.my.cnf", read_default_group="client", use_unicode=True, charset=dbencoding) dbConPool = Pool.Pool(ctor) def doSQL(SQL): """ executes the sql statement SQL and returns a list of tuples containing the results""" results = [] # SQL = SQL.encode(dbencoding, "backslashreplace") # DebugErr("executing " + SQL)