4

I have started writting rss reader in Vala, but I don't know, what database system should I use, I cannot connect to couchdb and sqlite works fine, but I would like use couchdb because of ubuntu one. I have natty with latest updates

public CouchDB.Session session;
    public CouchDB.Database db;
    public string feed_table = "feed";
    public string item_table = "item";
    public struct field {
        string name;
        string val;
    }

    // constructor
    public Database() {
    try {
    this.session = new CouchDB.Session();
     } catch (Error e) {
           stderr.printf ("%s a\n", e.message);
        }

    try {

         this.db = new CouchDB.Database (this.session, "test");
         } catch (Error e) {
           stderr.printf ("%s a\n", e.message);
        }

        try {
        this.session.get_database_info("test");
        } catch (Error e) {
           stderr.printf ("%s aa\n", e.message);
        }

         try {
          var newdoc = new CouchDB.Document ();
        newdoc.set_boolean_field ("awesome", true);
        newdoc.set_string_field ("phone", "555-VALA");
        newdoc.set_double_field ("pi", 3.14159);
        newdoc.set_int_field ("meaning_of_life", 42);
        this.db.put_document (newdoc);    // store document
        } catch (Error e) {
        stderr.printf ("%s aaa\n", e.message);
        } 

reports

$ ./xml_parser rss.xmlCannot connect to destination (127.0.0.1) aa
Cannot connect to destination (127.0.0.1) aaa
Oli
  • 299,380

1 Answers1

1

From a performance point of view, I'd just like to say that CouchDB perhaps isn't the fastest solution when compared to something more mature like SQLite. A gwibber comparison puts SQLite as just 10 times faster.

Given that a RSS reader does a lot more SELECT than INSERT, this is something you need to be conscious of because it's going to effect your application's responsiveness.


In terms of your code, comparing it to the "official" Vala+Couch sample, you're not passing in the connection details so I'm wondering if there's an issue with the auto-detect mechanism. Couch is started on a different port each time it runs but you can get its current port through dbus:

dbus-send --session --print-reply --dest=org.desktopcouch.CouchDB / org.desktopcouch.CouchDB.getPortmethod return sender=:1.231 -> dest=:1.230 reply_serial=2

I don't know the Vala for that but manually finding out might help you get the initial connection done.

Oli
  • 299,380