database format or scriptable export to CSV

I’m pretty new to user manager, but was wondering if it is possible to query the db via sql? Or alternatively, expert specific fields via command line to CSV? What I’m looking for is a way to export daily up and down traffic usage per username.