Posts Tagged ‘sql mode’

I’ve written a new article about how to query multiple databases using db-mode. It demonstrates quickly selecting between multiple databases using ido and you may be surprised to learn that it using a mechanism very similar to my directory aliases. This is a follow-up to my page on emacs db mode.

Why Should You Be Interested?

If you need to work with multiple databases and you like using emacs then the page is especially for you. Go take a look! It also has a good example of using the emacs mode line, in this case to display which database you are currently connected to. And finally it is another example of using ido which if you haven’t tried yet, you really should.

About The Code

The code is designed to work with my own db-mode as that is what I use but it could be easily adapted for use with sql-mode using the enter-db function from one of my earlier posts.

The preamble would be something like this:

;; ...
(let ((sql-sybase-program "/usr/bin/isql")
      (sql-server db-server)
      (sql-database db-database)
      (sql-user db-user)
      (sql-password db-password))
;; ...

Ian Eure also has a post on working with multiple databases here. It uses a new buffer for each database which is probably preferable to killing the connection.


Read Full Post »

So Ian Eure mistrusts my code because he thinks I don’t read documentation1. Nice. In fact, I did read that page before I implemented db mode. "Fantastic" I thought, "just what I need".

select count(*)
  from person

And what is the response from emacs?

No SQL process started.

Well gee, so much for the documentation2. At this point I figure that feature doesn’t work correctly and implement my own code, the core of which takes around 10 minutes.

Please understand that I’m not blaming the sql-mode author. It is probably obvious to him (and others) that you need to start the database before you start sql-mode. And I couldn’t help him improve his documentation beforehand either as I didn’t know what the problem was.

1. What is true is that I actually don’t read it particularly well.

2. Yes, I’m aware now that it only works in the opposite order.

Read Full Post »