Owncloud SQL manual export to .VCF & .ics

Because before Migrating anything I want to be sure I get my Contacts, and Caldendars items saved in a standard/open way.
so I got this SQL : SELECT fullname, carddata FROM contacts_cards WHERE addressbookid=2 ORDER BY fullname
but how can I export each rows in separated .vcf files ?

thank you