Changeset View
Changeset View
Standalone View
Standalone View
swh/core/db/__init__.py
Show First 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | def __init__(self, conn, pool=None): | ||||
""" | """ | ||||
self.conn = conn | self.conn = conn | ||||
self.pool = pool | self.pool = pool | ||||
def __del__(self): | def __del__(self): | ||||
if self.pool: | if self.pool: | ||||
self.pool.putconn(self.conn) | self.pool.putconn(self.conn) | ||||
def cursor(self, cur_arg): | def cursor(self, cur_arg=None): | ||||
"""get a cursor: from cur_arg if given, or a fresh one otherwise | """get a cursor: from cur_arg if given, or a fresh one otherwise | ||||
meant to avoid boilerplate if/then/else in methods that proxy stored | meant to avoid boilerplate if/then/else in methods that proxy stored | ||||
procedures | procedures | ||||
""" | """ | ||||
if cur_arg is not None: | if cur_arg is not None: | ||||
return cur_arg | return cur_arg | ||||
▲ Show 20 Lines • Show All 64 Lines • Show Last 20 Lines |