kaykay-dv / pocketsearch

A simple full-text search library for Python using SQLite and its FTS5 extension
https://pocketsearch.readthedocs.io/en/latest/
MIT License
1 stars 0 forks source link

Reader / Writer context manager #39

Closed kaykay-dv closed 1 year ago

kaykay-dv commented 1 year ago

Python Context Manager classes should be added for reading / writing from indices. Closing connections should be automatically handled by the context managers:

e.g.


from pocketsearch import PocketWriter

with PocketWriter() as pocket_writer
    pocket_writer.insert(text="Hello world.")
    self.assertEqual(pocketsearch.search().count(),1)

and


from pocketsearch import PocketReader

with PocketReader() as pocket_reader:
    self.assertEqual(pocket_reader.search(text="Hello world.").count(),0)
kaykay-dv commented 1 year ago

Implemented in 0.12