...
 
Commits (4)
......@@ -13,7 +13,7 @@
Импопрт основного класса:
`from idmapper import IdMapper, get_writer, get_reader`
`from idmapper import IdMapper, get_writer, get_reader, Backends`
Создание экземпляра:
......@@ -43,41 +43,45 @@
Сохранение в файл:
`wf = get_writer(file_path='1.txt')`
`idm.save(wf)`
```python
with get_writer(backend=Backends.file, file_path='1.txt') as wf:
idm.save(wf)
```
Загрузка из файла:
`rf = get_reader(file_path='1.txt')`
`idm_new = IdMapper()`
`idm_new.load(rf)`
```python
idm_new = IdMapper()
with get_reader(backend=Backends.file, file_path='1.txt') as rf:
idm_new.load(rf)
`idm_new.get_uuid('123')`
print(idm_new.get_uuid('123'))
```
`>>>'bdf6235f-cd03-4e48-98c4-0e35bc37d58e'`
Сохранение в БД tarantool:
`import tarantool`
`cn = tarantool.connect('localhost', 3301)`
```python
import tarantool
`wdb = get_writer(connector=cn, space='test_1')`
cn = tarantool.connect('localhost', 3301)
`idm.save(wdb)`
with get_writer(backend=Backends.tnt, connector=cn, space='test_1') as wdb:
idm.save(wdb)
```
Загрузка из БД tarantool:
`rdb = get_reader(connector=cn, space='test_1')`
```python
idm_new = IdMapper()
`idm_new = IdMapper()`
`idm_new.load(rdb)`
with get_reader(backend=Backends.tnt, connector=cn, space='test_1') as rdb:
idm_new.load(rdb)
`idm_new.get_uuid('123')`
print(idm_new.get_uuid('123')`)
```
`>>>'bdf6235f-cd03-4e48-98c4-0e35bc37d58e'`
......
......@@ -103,7 +103,8 @@ class IdMapperReader(metaclass=ABCMeta):
class IdMapperTntReader(IdMapperReader):
def __exit__(self, exc_type, exc_val, exc_tb):
self._connector.close()
# self._connector.close()
pass
def __init__(self, connector, mapping_name, cid, max_items=MAX_DB_ITEMS):
"""
......@@ -229,7 +230,8 @@ class IdMapperTntWriter(IdMapperWriter):
raise DbMapperError(exc=e)
def __exit__(self, exc_type, exc_val, exc_tb):
self._connector.close()
# self._connector.close()
pass
def write(self, data):
try:
......
......@@ -3,7 +3,7 @@ from setuptools import setup
setup(
name='idmapper',
version='0.1.6',
version='0.1.7',
packages=['idmapper', ],
url='https://gitlab.itnap.ru/open-source/py-id-mapper',
license='',
......