def _makeTxPostgres(parsed, connections=1): from norm.tx_postgres import DictConnection pool = ConnectionPool() pool.db_scheme = 'postgres' connstr = mkConnStr(parsed) dlist = [] for i in xrange(connections): conn = DictConnection() d = conn.connect(connstr) d.addCallback(lambda _: pool.add(conn)) dlist.append(d) ret = defer.gatherResults(dlist) return ret.addCallback(lambda _: pool)
def connect(): conn = DictConnection() d = conn.connect(connstr) return d.addCallback(lambda _: conn)