I am looking for a database library that can be used within an editor to replace a custom document format. In my case the document would contain a functional program.
我正在寻找一个可以在编辑器中使用的数据库库来替换自定义文档格式。在我的情况下,该文件将包含一个功能程序。
I want application data to be persistent even while editing, so that when the program crashes, no data is lost. I know that all databases offer that.
我希望即使在编辑时应用程序数据也是持久的,这样当程序崩溃时,不会丢失任何数据。我知道所有数据库都提供了这一点。
On top of that, I want to access and edit the document from multiple threads, processes, possibly even multiple computers.
最重要的是,我想从多个线程,进程甚至多台计算机访问和编辑文档。
Format: a simple key/value database would totally suffice. SQL usually needs to be wrapped, and if I can avoid pulling in a heavy ORM dependency, that would be splendid.
格式:一个简单的键/值数据库就足够了。 SQL通常需要被包装,如果我可以避免引入繁重的ORM依赖,那将是非常出色的。
Revisions: I want to be able to roll back changes up to the first change to the document that has ever been made, not only in one session, but also between sessions/program runs.
修订:我希望能够将更改回滚到对文档的第一次更改,不仅在一个会话中,而且在会话/程序运行之间。
I need notifications: each process must be able to be notified of changes to the document so it can update its view accordingly.
我需要通知:每个进程必须能够通知文档的更改,以便相应地更新其视图。
I see these requirements as rather basic, a foundation to solve the usual tough problems of an editing application: undo/redo, multiple views on the same data. Thus, the database system should be lightweight and undemanding.
我认为这些要求是基本的,是解决编辑应用程序常见难题的基础:撤消/重做,对同一数据的多个视图。因此,数据库系统应该是轻量级的并且要求不高。
Thank you for your insights in advance :)
感谢您提前获得的见解:)
3 个解决方案
#1
Berkeley DB is an undemanding, light-weight key-value database that supports locking and transactions. There are bindings for it in a lot of programming languages, including C++ and python. You'll have to implement revisions and notifications yourself, but that's actually not all that difficult.
Berkeley DB是一个不需要的,轻量级的键值数据库,支持锁定和事务。在很多编程语言中都有绑定,包括C ++和python。您必须自己实施修订和通知,但实际上并不是那么困难。
#2
It might be a bit more power than what you ask for, but You should definitely look at CouchDB.
它可能比你要求的更强大,但你应该看看CouchDB。
It is a document database with "document" being defined as a JSON record. It stores all the changes to the documents as revisions, so you instantly get revisions. It has powerful javascript based view engine to aggregate all the data you need from the database.
它是一个文档数据库,“document”被定义为JSON记录。它将所有对文档的更改存储为修订版,因此您可以立即获得修订。它具有强大的基于javascript的视图引擎,可以从数据库中聚合所需的所有数据。
All the commits to the database are written to the end of the repository file and the writes are atomic, meaning that unsuccessful writes do not corrupt the database.
对数据库的所有提交都写入存储库文件的末尾,并且写入是原子的,这意味着不成功的写入不会破坏数据库。
Another nice bonus You'll get is easy and flexible replication and of your database.
您将获得的另一个好处是简单灵活的复制和数据库。
See the full feature list on their homepage
查看其主页上的完整功能列表
On the minus side (depending on Your point of view) is the fact that it is written in Erlang and (as far as I know) runs as an external process...
在负面(取决于你的观点)是它是用Erlang编写的,并且(据我所知)作为外部进程运行...
I don't know anything about notifications though - it seems that if you are working with replicated databases, the changes are instantly replicated/synchronized between databases. Other than that I suppose you should be able to roll your own notification schema...
我对通知一无所知 - 似乎如果您正在使用复制数据库,那么更改会立即在数据库之间进行复制/同步。除此之外我想你应该能够推出自己的通知模式......
#3
Check out ZODB. It doesn't have notifications built in, so you would need a messaging system there (since you may use separate computers). But it has transactions, you can roll back forever (unless you pack the database, which removes earlier revisions), you can access it directly as an integrated part of the application, or it can run as client/server (with multiple clients of course), you can have automatic persistency, there is no ORM, etc.
查看ZODB。它没有内置通知,因此您需要一个消息传递系统(因为您可以使用单独的计算机)。但是它有事务,你可以永远回滚(除非你打包数据库,这删除了早期版本),你可以直接作为应用程序的集成部分访问它,或者它可以作为客户端/服务器运行(当然有多个客户端) ),你可以有自动持久性,没有ORM等。
It's pretty much Python-only though (it's based on Pickles).
它几乎只是Python(它基于Pickles)。
http://en.wikipedia.org/wiki/Zope_Object_Database
http://pypi.python.org/pypi/ZODB3
#1
Berkeley DB is an undemanding, light-weight key-value database that supports locking and transactions. There are bindings for it in a lot of programming languages, including C++ and python. You'll have to implement revisions and notifications yourself, but that's actually not all that difficult.
Berkeley DB是一个不需要的,轻量级的键值数据库,支持锁定和事务。在很多编程语言中都有绑定,包括C ++和python。您必须自己实施修订和通知,但实际上并不是那么困难。
#2
It might be a bit more power than what you ask for, but You should definitely look at CouchDB.
它可能比你要求的更强大,但你应该看看CouchDB。
It is a document database with "document" being defined as a JSON record. It stores all the changes to the documents as revisions, so you instantly get revisions. It has powerful javascript based view engine to aggregate all the data you need from the database.
它是一个文档数据库,“document”被定义为JSON记录。它将所有对文档的更改存储为修订版,因此您可以立即获得修订。它具有强大的基于javascript的视图引擎,可以从数据库中聚合所需的所有数据。
All the commits to the database are written to the end of the repository file and the writes are atomic, meaning that unsuccessful writes do not corrupt the database.
对数据库的所有提交都写入存储库文件的末尾,并且写入是原子的,这意味着不成功的写入不会破坏数据库。
Another nice bonus You'll get is easy and flexible replication and of your database.
您将获得的另一个好处是简单灵活的复制和数据库。
See the full feature list on their homepage
查看其主页上的完整功能列表
On the minus side (depending on Your point of view) is the fact that it is written in Erlang and (as far as I know) runs as an external process...
在负面(取决于你的观点)是它是用Erlang编写的,并且(据我所知)作为外部进程运行...
I don't know anything about notifications though - it seems that if you are working with replicated databases, the changes are instantly replicated/synchronized between databases. Other than that I suppose you should be able to roll your own notification schema...
我对通知一无所知 - 似乎如果您正在使用复制数据库,那么更改会立即在数据库之间进行复制/同步。除此之外我想你应该能够推出自己的通知模式......
#3
Check out ZODB. It doesn't have notifications built in, so you would need a messaging system there (since you may use separate computers). But it has transactions, you can roll back forever (unless you pack the database, which removes earlier revisions), you can access it directly as an integrated part of the application, or it can run as client/server (with multiple clients of course), you can have automatic persistency, there is no ORM, etc.
查看ZODB。它没有内置通知,因此您需要一个消息传递系统(因为您可以使用单独的计算机)。但是它有事务,你可以永远回滚(除非你打包数据库,这删除了早期版本),你可以直接作为应用程序的集成部分访问它,或者它可以作为客户端/服务器运行(当然有多个客户端) ),你可以有自动持久性,没有ORM等。
It's pretty much Python-only though (it's based on Pickles).
它几乎只是Python(它基于Pickles)。
http://en.wikipedia.org/wiki/Zope_Object_Database
http://pypi.python.org/pypi/ZODB3