How can I make SQL queries from within emacs scripts to MySql then print the result set?
#!/usr/bin/emacs --script (setq sql "select id, name from foobar order by name ") (princ sql)
How can I make SQL queries from within emacs scripts to MySql then print the result set?
#!/usr/bin/emacs --script (setq sql "select id, name from foobar order by name ") (princ sql)
These may assist you:
http://www.emacswiki.org/emacs/SqlMode
http://atomized.org/2008/10/enhancing-emacs%E2%80%99-sql-mode/
If you need a really reliable way to use mysql I would suggest using python mysql libraries via pymacs.
If you need it just working use mysql comand line client? Mysql is quite easy to use in scripts. Check out the example below
$ mysql -u root -p<password> -B <db> --execute="select * from projects"
p_id p_timestamp p_name p_manager_id p_status
1 2009-04-14 14:42:00 Test1 3 1
2 2009-04-14 14:42:13 Test2 3 1
The output should be easy to interpret as it looks like tab separated CSV. So it should be ok for most scenarios.