Use SQLite as a key:value store

前端 未结 2 1273
不思量自难忘°
不思量自难忘° 2020-12-16 07:31

As suggested in comments from Key: value store in Python for possibly 100 GB of data, without client/server and in other questions, SQLite could totally be used as a persist

2条回答
  •  自闭症患者
    2020-12-16 08:32

    There is already sqlitedict which appears to meet all your needs.

    From the documentation:

    >>> from sqlitedict import SqliteDict
    >>> mydict = SqliteDict('./my_db.sqlite', autocommit=True)
    >>> mydict['some_key'] = any_picklable_object
    >>> print mydict['some_key']  # prints the new value
    >>> for key, value in mydict.iteritems():
    >>>     print key, value
    >>> print len(mydict) # etc... all dict functions work
    >>> mydict.close()
    

提交回复
热议问题