diff --git a/pg_store/store.py b/pg_store/store.py index 12d6aaf..13738c5 100644 --- a/pg_store/store.py +++ b/pg_store/store.py @@ -22,6 +22,7 @@ import psycopg2 from functools import wraps +from collections import namedtuple from pulsar.apps.data import RemoteStore from concurrent.futures import TimeoutError @@ -54,7 +55,9 @@ def _init(self, **kwargs): self._pool = aiopg.pool.Pool( self.buildurl(), minsize=self.pool_size, maxsize=self.pool_size, loop=self._loop, timeout=self.timeout, enable_json=True, - enable_hstore=True, enable_uuid=True, echo=False, on_connect=None) + enable_hstore=True, enable_uuid=True, echo=False, on_connect=None, + pool_recycle=-1 + ) @property def pool(self): @@ -142,6 +145,14 @@ async def fetch_list(self, *args, **options): return [{col.name: val for col, val in zip(desc, row)} for row in rows] + async def fetch_inst(self, *args, **options): + data = await self.fetch_object(*args, **options) + return namedtuple('Obj', data.keys())(**data) + + async def fetch_inst_list(self, *args, **options): + data = await self.fetch_list(*args, **options) + return [namedtuple('Obj', item.keys())(**item) for item in data] + def safe_fetch_list(self, *args, **options): return safe(self.fetch_list, *args, **options) diff --git a/setup.py b/setup.py index 87da67c..2c431a6 100644 --- a/setup.py +++ b/setup.py @@ -4,14 +4,14 @@ setup( name='pulsar-postgresql', - version='0.1.2', + version='0.2.0', author='Dmitriy Vlasov', author_email='scailer@yandex.ru', packages=['pg_store'], include_package_data=True, - install_requires=['aiopg==0.13.0'], - requires=['aiopg', 'pulsar (>= 1.5.4)'], + install_requires=['aiopg==0.16'], + requires=['aiopg (>= 0.16)', 'pulsar (>= 2.0.2)'], url='https://github.com/scailer/pulsar-postgresql', license='MIT license',