Hey all,
I am trying to connect to a remote database and replace its files. I am using db:replace() inside client:query(), but I don't get how I am supposed to pass $input as the new data for the file in the database.
Here a quick code snippet I put together: http://sprunge.us/jdaZ ( or http://sprunge.us/OZHj?xquery )
If there's a better method for doing what I am trying, I'm fine with replacing my whole method, even if that is using some sort of REST API and http requests. Just give me some pointers ;)
Thanks!
Hi Asxetos,
Here a quick code snippet I put together: http://sprunge.us/jdaZ ( or http://sprunge.us/OZHj?xquery )
If you use db:replace, you should probably specify your document inside the query.
However, the REST API may be more appropriate for your scenario. Did you already have a look at our documentation [1]? If you want to send your request via XQuery, you can use the HTTP Module [2].
Hope this helps, Christian
[1] http://docs.basex.org/wiki/Developer_Section [2] http://docs.basex.org/wiki/HTTP_Module
If there's a better method for doing what I am trying, I'm fine with replacing my whole method, even if that is using some sort of REST API and http requests. Just give me some pointers ;)
Thanks!
On 2 June 2016 at 17:15, Christian Grün christian.gruen@gmail.com wrote:
Hi Asxetos,
Here a quick code snippet I put together: http://sprunge.us/jdaZ ( or http://sprunge.us/OZHj?xquery )
If you use db:replace, you should probably specify your document inside the query.
yeah, my guess is that I'd have to serialize the document in some way because it exists on the local filesystem, but not on the remote. So, I am reading the document, but cannot just concat it in the query. It also feels wrong.
However, the REST API may be more appropriate for your scenario. Did you already have a look at our documentation [1]? If you want to send your request via XQuery, you can use the HTTP Module [2].
Yep, the REST API seems to be it. I've already tried it with Postman. And yes, I'll probably use the HTTP xq module. It'd be nice if there was a way trigger a backup with the REST API, but I guess it's not a big deal.
Hope this helps, Christian
[1] http://docs.basex.org/wiki/Developer_Section [2] http://docs.basex.org/wiki/HTTP_Module
bwt, that was a super fast response! Thanks!
It'd be nice if there was a way trigger a backup with the REST API, but I guess it's not a big deal.
The easiest way I guess is to use the GET method and the command operation:
http://localhost:8984/rest?command=create+backup+name-of-your-database
bwt, that was a super fast response! Thanks!
You are welcome ;)
aha! it seems the REST API[0] does work! I guess I can do my db:replace() using HTTP PUT requests
[0]: http://docs.basex.org/wiki/REST [1]: http://docs.basex.org/wiki/REST#PUT_Method
On 2 June 2016 at 17:09, Asxetos pure.asxetos@gmail.com wrote:
Hey all,
I am trying to connect to a remote database and replace its files. I am using db:replace() inside client:query(), but I don't get how I am supposed to pass $input as the new data for the file in the database.
Here a quick code snippet I put together: http://sprunge.us/jdaZ ( or http://sprunge.us/OZHj?xquery )
If there's a better method for doing what I am trying, I'm fine with replacing my whole method, even if that is using some sort of REST API and http requests. Just give me some pointers ;)
Thanks!
basex-talk@mailman.uni-konstanz.de