If you know the iMessage account of your contact you can do following : 

    $ sqlite ~/Library/Messages/chat.db
    .output chatfile;
    select text from message where handle_id=((select ROWID from chat where guid="iMessage;-;+#########")-1);

Replace the `#####` by the iMessage account. In my case it is +33616.... (yes with the prefix)