views:

423

answers:

7

Do you know any SQLite-like database that stores its data in easily readable plain text format (like multi-line json or yaml)?

I'd like to store some data along with my project in version control system but if I use sqlite I can't merge data changes that occurred in different working copies.

I don't want to use just some kind of config file because I want my program to be able to modify this data and query it efficiently without loading all data into memory.

Data in database might be accessed through some kind of sql dialect but that is not a requirement.

EDIT:

I am seeking for something that builds and maintains index file for json/yaml/whatever that allows for accessing fragments of the data as fast as proper database can do it.

I also require ability to modify the data so solutions that allow only for querying are not enough.

+2  A: 

Most programming languages come with tools to serialize and unserialize their native data structures. Use those to store the data in text files.

This way you'll have data that is compliant and supported with your programming language without the need of slow parsers.

For example in PHP you could use the serialize() function to turn any data structure into a string (unserialize() does the opposite).

The querying becomes as simple as accessing native data structures, no need for the complication/slowness of SQL.

Luca Matteis
A: 

Xml, With Linq-To-Xml?

Human Readable and can be partially updated or read in all at once.

ck
xml is good enough, but I need something that could be used especially from php and python
Kamil Szot
+1  A: 

In my youth, there existed some kind of of awk-based database engine. It was just a set of shell-scripts. But I don't remember its name and I don't know if it was SQL-compliant or free.

But the stored data was totally text based.

I did not find it there, but also this link might be of use:

Catalog of free databases

Juergen
You're thinking of `qawk`, which can be found at http://cm.bell-labs.com/cm/cs/awkbook/ as the examples. I suggest downloading the .txt version which, of course, is an awk script that auto-extracts all the examples from the book. The clever thing about `qawk` was that tables were stored in flat files (with field names as the first line) and qawk would automatically do joins to generate a table that contained every field name in your query. I suspect it's not really what's being looked for, but it's a classic bit of Bell Labs smart-guy software.
Dale Hagglund
+2  A: 

This might not be exactly what you work looking for, but I think something like CouchDB would be an excellent choice for this kind of application. It is queried via json but I don't think the stored data is directly editable.

ternaryOperator
I like the ideas of CouchDB. Especially how indexes are built but I'm seeking something that is to CouchDB as Sqlite is to MySql
Kamil Szot
+2  A: 

Flat file database shows that the idea isn't too stretched...

I wonder why your requirements excludes "loading all data into memory". Do you think you will have several GB of "some data"? Even some MB of data shouldn't be too much to load and maintain in memory, after all a browser consumes much more memory with the Dom of a large Web page...

I suppose you can use memory-mapped file to reduce memory usage, but maintaining an accurate index might be more challenging.
I wonder if Thunderbird, which stores the mailboxes in plain text files (mbox format), uses such technique.

PhiLho
Memory and speed are constraints because I want to use it in web application reading some records at each requests. I don't want to share memory across requests so script servicing each request is on is own and should not grab too much memory (even few megs might be too much).Thunderbird is nice example. There is a flat data file and index file taht allows for fast access. If index file is corrupted or out of date you can simply delete it and have it regenerated.
Kamil Szot
OK, I was thinking of desktop applications instead. Your arguments are convincing.MongoDB mentioned by valya seems adapted to Web applications (most or all of featured applications are Web app) but it still uses a binary storage, if I understood correctly.An alternative (a bit clumsy) is to export DB content for versioning purpose, and perhaps for merge (to re-import later). Might be problematic with a server in production usage...
PhiLho
[Mimesis](http://mimesis.110mb.com/ "Mimesis") mentioned in the Wikipedia article is a textual database written in PHP. Might be what you are looking for. If PHP is an option for you (you haven't mentioned a language...).
PhiLho
+3  A: 

MongoDB has a lot in common with CouchDB, but simpler.

You can try my library (be careful) http://code.google.com/p/mongodloid/ to make your life even easier

valya
+1  A: 

Berkeley XML DB? http://www.oracle.com/database/berkeley-db/xml/index.html

Theo