MageRun offers a way to run SQL queries.
It would be a great addition if the results could also be exported to CSV format.
I'm not sure if this feature already exists and I might have just missed it.
Something like:
n98-magerun2 db:query "SELECT sku, name FROM catalog_product_entity" --format=csv > products.csv