See they database replicator and extract the connect and query function.
It's obviously just a database, so you can run whatever queries you want on it. That being said, we don't suggest people doing this. We've set up an entire API (Core and proxies for java actions) to query the database in a safe way. This ensures that (most) scary queries are avoided and that all of the database stuff is abstracted away (which is the entire point of mendix :))
If you're missing any particular type of query, I'd really suggest filing a feature request, so that we can ensure that those types of queries are dealt with in a safe manner (and that they don't break between versions!)