Interacting with databases

Hello,

During one of the sessions at Balisage, someone asked if BaseX could be used for the p:xquery step. I thought that sounded like a good idea.

I downloaded a copy of BaseX and fairly quickly hacked my way to a step that connects to a BaseX instance, sends it the query, and returns the results. (I was going to do the same thing with eXist-db, but exist-db.org is down at the moment and I don’t have it locally.)

That “basex-xquery” step is okay as far as it goes. Each time the step is run, it’s going to make a new connection. That might be time consuming. It also means that you can’t start a transaction, do a couple of queries, then end the transaction or roll it back, or whatever. (I have no idea what the BaseX transaction model is, but even if that’s not how BaseX works, it’s how some database *could* work).

I think you might be able to go a little further by having an “open session” step that returns a binary document that is, effectively, the session object. Then you could have “query” and “close session” steps that take that document as a parameter.

But there are also other commands that you might want to send to a database that might not be possible in a query: add these documents, create this index, add this user, drop this database, etc.

I guess you could have steps for each of those commands too, but is that the best answer?

Has anyone been thinking about this kind of problem?

                                        Be seeing you,
                                          norm

--
Norm Tovey-Walsh <ndw@nwalsh.com>
https://norm.tovey-walsh.com/

> Sometimes in life situations develop that only the half-crazy can get
> out of.--La Rochefoucauld

Received on Saturday, 9 August 2025 12:15:49 UTC