How to delete selected documents from database
Tuesday, 7 December 2010 · 2 messages
JC
Jan Vlčinský (CAD)7 Dec 2010 12:39 #
Hi
So far I was adding documents and querying using Python API (generally sending commands to BaseX).
Now I need to delete some documents. What is the most effective method?
1. drop db
I would have to recreate it very soon.
I am a bit concerned by other clients being connected to the same database
2. loop in Python performing delete command one document by one
3. do some sort of xquery in style "for $doc in collection() return (delete base-uri($doc))"
Note, that this does not work, but there might be some way like this similar to insert or update mechanism
Any ideas or hints?
Thanks for advice
Jan
--
*Ing. Jan Vlčinský*
CAD programy
Slunečnicová 338/3, 734 01 Karviná Ráj, Czech Republic
tel: +420-597 602 024; mob: +420-608 979 040
skype: janvlcinsky; GoogleTalk: jan.vlcinsky at gmail.com
http://cz.linkedin.com/in/vlcinsky
AW
Andreas Weiler7 Dec 2010 13:00 #
Hi Jan,
the second option is the only one which will be successful.
just send:
delete "document-name" to the server.
Note: If documents have the same name, all of them will be deleted.
The first option is not working cause dropping of a database is not allowed if other clients have the database opened in their context. The third option is not working cause XQuery Update is not intended to delete whole documents from a database.
Kind regards,
Andreas
Quoted text · Jan Vlčinský (CAD) · 36 lines
Am 07.12.10 12:39, schrieb Jan Vlčinský (CAD): > Hi > So far I was adding documents and querying using Python API (generally > sending commands to BaseX). > > Now I need to delete some documents. What is the most effective method? > > 1. drop db > I would have to recreate it very soon. > I am a bit concerned by other clients being connected to the > same database > 2. loop in Python performing delete command one document by one > 3. do some sort of xquery in style "for $doc in collection() return > (delete base-uri($doc))" > Note, that this does not work, but there might be some way like > this similar to insert or update mechanism > > Any ideas or hints? > > Thanks for advice > > Jan > -- > *Ing. Jan Vlčinský* > CAD programy > Slunečnicová 338/3, 734 01 Karviná Ráj, Czech Republic > tel: +420-597 602 024; mob: +420-608 979 040 > skype: janvlcinsky; GoogleTalk: jan.vlcinsky at gmail.com > <mailto:jan.vlcinsky at gmail.com> > http://cz.linkedin.com/in/vlcinsky > > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
Written for BaseX 6. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery