basex.session
add
(add session path xml-stream)
Adds the XML stream specified by [input] to the currently opened database at
the specified [path]. A document with the same path may occur than once in a
database. If this is unwanted, replace can be used.
close
(close session)
Closes the currently open session.
create
(create session name xml-stream)
Creates the database name with an input and opens it. An existing database
will be overwritten.
create-session
(create-session)
(create-session db-spec)
Creates a new TCP session to an existing BaseX server. Can be called with or
without a db-spec. If a db-spec is provided it doesn't need to be complete
as the values will be merged with the default settings:
{ :host "localhost"
:port 1984
:username "admin"
:password "admin" }
Returns the connected session. Throws IOException if it can't connect or the
username or password is incorrect.
execute
(execute session command output-stream)
(execute session command)
Sends commands to the BaseX server via the provided session. Can be passed
an output stream to collect the server response or, if one is not provided,
it will simply return the server response as a string from the call.
info
(info session)
Shows global information.
replace
(replace session path xml-stream)
Replaces a document in the currently opened database, addressed by [path],
with the XML stream specified by [xml-stream], or adds a new document if the
resource does not exist yet.
store
(store session path blob-stream)
Stores a raw file in the opened database to the specified [path]
with-session
macro
(with-session bindings & body)
Simple macro that allows clean handling of session. Wraps statements in a
try block that will attempt to close the session in the finally block.
Bindings should start with the session declaration but contain as many
declarations as you need
(with-session [session (basex.session/create-session)
query "xquery 1 to 5"]
(println (basex.session/execute query)))
In the case above the session and query bindings will be available for use
in the body of the form. The session will be closed when the form completes