I am targeting an application that would incorporate BaseX databases into larger projects, each following a standard file tree. As such, it is necessary for the application to interact with a database given by some path relative to the working directory.
The application is structured as to provide query files through the command line in a standalone invocation.
The documentation explains that the normal case is to resolve a directory in which all databases are stored, with each separate database in a sub-directory having the same name as the database.
What support is available for the case in which the application must resolve the path to the database independent of the normal rules?
Hi Eric,
It’s not possible to specify a dynamic path to a single database, but you can change the path to the database directory before you start BaseX. This can e.g. be done via system properties, either on command line …
java -Dorg.basex.dbpath=/custom/path/ -cp basex.jar org.basex.BaseX
…or via Java:
System.setProperty('org.basex.dbpath', '/custom/path/');
Please note that DBPATH is a “global option” [1]. As such, it cannot be changed anymore after BaseX has been started.
Best, Christian
[1] https://docs.basex.org/wiki/Options
On Thu, Feb 17, 2022 at 4:54 AM Eric Levy contact@ericlevy.name wrote:
I am targeting an application that would incorporate BaseX databases into larger projects, each following a standard file tree. As such, it is necessary for the application to interact with a database given by some path relative to the working directory.
The application is structured as to provide query files through the command line in a standalone invocation.
The documentation explains that the normal case is to resolve a directory in which all databases are stored, with each separate database in a sub-directory having the same name as the database.
What support is available for the case in which the application must resolve the path to the database independent of the normal rules?
Thank you for the clear explanation.
I am struggling at the moment to see a means for integrating BaseX into my application as I had originally planned.
The only possibility seems to be to give the parent directory of the database location as a Java property, and to give the base name of the directory as the database name. In practice, this approach would have limited reliability and maintainability.
I had hoped that BaseX would support embedded use cases following the same pattern of well-known examples, such as SQLite, in which a database is commonly given as part of a larger project, or as a project itself, identified simply by its path. (As a concrete example that comes to mind, I recently installed the client for Nextcloud, which supports selection of arbitrary local directories for synchronization against a server, and stores the current state information in a database at the base of the tree targeted for synchronization. Discoverability of the database at the base of the tree is an essential feature of the application logic.)
I would be happy to learn of a viable way to integrate with BaseX, but I feel it may not be feasible given the limitation.
On Thu, 2022-02-17 at 14:34 +0100, Christian Grün wrote:
Hi Eric,
It’s not possible to specify a dynamic path to a single database, but you can change the path to the database directory before you start BaseX. This can e.g. be done via system properties, either on command line …
java -Dorg.basex.dbpath=/custom/path/ -cp basex.jar org.basex.BaseX
…or via Java:
System.setProperty('org.basex.dbpath', '/custom/path/');
Please note that DBPATH is a “global option” [1]. As such, it cannot be changed anymore after BaseX has been started.
Best, Christian
[1] https://docs.basex.org/wiki/Options
On Thu, Feb 17, 2022 at 4:54 AM Eric Levy contact@ericlevy.name wrote:
I am targeting an application that would incorporate BaseX databases into larger projects, each following a standard file tree. As such, it is necessary for the application to interact with a database given by some path relative to the working directory.
The application is structured as to provide query files through the command line in a standalone invocation.
The documentation explains that the normal case is to resolve a directory in which all databases are stored, with each separate database in a sub-directory having the same name as the database.
What support is available for the case in which the application must resolve the path to the database independent of the normal rules?
basex-talk@mailman.uni-konstanz.de