Easy way to serialize a DB to files?

Saturday, 18 May 2013 · 2 messages · last reply 19 May 2013
DK
Dirk Kirstenin reply to Francis Avila, 19 May 2013, 01:0518 May 2013 23:09 #
Dear Francis, There is the Export command, which should do exactly what you want. Read more about it here: http://docs.basex.org/wiki/Commands#EXPORT Cheers, Dirk
Quoted text · Francis Avila · 19 lines
On 05/18/2013 11:05 PM, Francis Avila wrote: > Is there an easy way to save/export/serialize an entire database to the filesystem? (I don't mean CREATE BACKUP/RESTORE. I mean if you want to get plain XML files for something outside of BaseX.) > > I have been using this XQuery: > > let $base := 'some/path/' > for $doc in db:open('dbname') > let $fn := $base || document-uri($doc) > let $dir := file:dir-name($fn) > return ( > if (not(file:exists($dir))) then file:create-dir($dir) else (), > file:write($fn, $doc, map{"method":="xml"}) > ) > > However this uses a large amount of memory so any large database needs to be manually partitioned into multiple XQueries. > > It seems like there should be a very simple way to do this. > >
-- Dirk Kirsten, BaseX GmbH, http://basex.org |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer: | Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle `-- Phone: 0049 7531 28 28 676, Fax: 0049 7531 20 05 22
FA
Francis Avila19 May 2013 01:05 #
Is there an easy way to save/export/serialize an entire database to the filesystem? (I don't mean CREATE BACKUP/RESTORE. I mean if you want to get plain XML files for something outside of BaseX.) I have been using this XQuery:
let $base := 'some/path/'
for $doc in db:open('dbname')
let $fn := $base || document-uri($doc)
let $dir := file:dir-name($fn)
return (
	if (not(file:exists($dir))) then file:create-dir($dir) else (),
	file:write($fn, $doc, map{"method":="xml"})
)
However this uses a large amount of memory so any large database needs to be manually partitioned into multiple XQueries. It seems like there should be a very simple way to do this.
-- Francis Avila Web Developer Dancing Mammoth, Inc. (Formerly PJ Doland Web Design, Inc.) E: favila at dancingmammoth.com http://dancingmammoth.com

⚡Generated with XQuery