joereynolds / SQHell.vim

An SQL wrapper for vim
MIT License
131 stars 9 forks source link

Export to CSV? #33

Open joereynolds opened 6 years ago

joereynolds commented 6 years ago

Could be a potential thing to add

How it should work: Call sqhell#Export This will proxy down to the provider of choice. We'll need to store the last query executed so we can re-run it and export it. Since we can have multiple windows, to avoid conflicts, we should store the query in a variable that also contains the SQHResult buffer's id.

A MySql version will work like this

:SQHExport -> sqhell#Export() -> mysql#Export()

Runs the current query and appends the following

INTO OUTFILE 'argument from SQHExecute'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n';

Note that this only works on selects, obviously.