Is there a way to pass commands from SQLite
into ruby script?
For example I have a test.sqlite
database created. Now I want to export a query result from that database into .csv
file. I can simply do that using command line:
Sqlite3 "H:\\test.sqlite"
.mode csv
.headers on
.once test.csv
select * from cars;
Sqlite3 "H:\\test.sqlite"
.mode csv
.headers on
.once test.csv
select * from cars;
or also using SQLite3:
sqlite3 -header -csv sqlite3 -header -csv H:\test.sqlite< query.sql > test.csv
and it works perfectly fine in CMD but I want to have that coded in my ruby script. I was also trying to pass that into command line using %x
but it is not working.
Any help?