Hi Ben,

> Is it possible to change the query-statement in such a way that the
> results are added to MariaBases/<DB-schema>/<table-name>?

If I get you right, you would like to read your tabular MariaDB data
via SQL select statements and add the contents to your new BaseX
database, right?

You might want to do something as follows:

sql:init('org.mariadb.jdbc.Driver'),

(: connect to the database, read table contents :)
let $db := '<DB-name>'
let $table := 'Mdw_Wens'
let $con := sql:connect(
  'jdbc:mariadb://localhost:3306/' || $db,
  '<user>', '<password>'
)
let $rows := sql:execute($con, 'select * from ' || $table)
(: create new document with transformed table contents :)
let $doc := element { $table } {
  for $row in $rows
  return element row {
    for $col in $row/sql:column
    return element { $col/@name } { $col/data() }
  }
}
(: add new document to your BaseX database :)
return db:add($db, $doc, $table || '.xml')

Could you give us little examples for <DB-name>, <DB-schema> and <table-name> ?

Best,
Christian

Reply via email to