Share a dict with multiple Python scripts

后端 未结 8 1176
予麋鹿
予麋鹿 2020-12-14 11:31

I\'d like a unique dict (key/value) database to be accessible from multiple Python scripts running at the same time.

If script1.py updates

8条回答
  •  清歌不尽
    2020-12-14 11:59

    It sounds like you really need is a database of some kind.

    If redis won't work for windows, then I would look at MongoDB.

    https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/

    MongoDB works great with python and can function similar to redis. Here are the install docs for PyMongo: http://api.mongodb.com/python/current/installation.html?_ga=2.78008212.1422709185.1517530606-587126476.1517530605

    Also, many people have brought up SQlite. I think you were concerned that it only allows one writer at a time, but this is not really a problem for you to worry about. I think what it is saying is that, if there are two writers, the second will be blocked until the first is finished. This is probably fine for your situation.

提交回复
热议问题