all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Problems trying to use MySQL in conjunction with Emacs
@ 2011-02-01 13:32 MBR
  0 siblings, 0 replies; 3+ messages in thread
From: MBR @ 2011-02-01 13:32 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 4505 bytes --]

I'm running into a problem trying to use MySQL in conjunction with 
Emacs.  Let me start by giving the relevant version information:

     Local OS: Windows XP, SP3
     Terminal emulator/SSH client: Putty 0.58
     Remote OS: Linux 2.6.18
     Emacs version (running on remote OS): 21.4.1
     MySQL version (running on remote OS): 5.0.91

I always have a shell buffer running inside Emacs, and I'd like to run 
the command 'mysql' so I can run SQL queries.  But if I type

     mysql -uuserid -ppassword

it just hangs.  When I kill the mysql process, it reports:

     bash: [5423: 2] tcsetattr: Invalid argument

Years ago I wrote C code that called tcsetattr() to set flags for the 
tty device driver.  I remember it being based on the idea that a tty was 
connected via RS-232, and many of the attributes you set via tcsetattr() 
controlled characteristics of the RS-232 connection - baud rate, parity, 
etc.  Obviously, for pseudo-ttys, most of that is irrelevant.  It looks 
like the 'mysql' executable is trying to do some hardware control that 
doesn't work in the context of an Emacs shell buffer.

As I investigated further, I discovered that Emacs has a Lisp function 
named sql-mysql which sounds like it runs MySQL queries directly.  That 
sounded good to me.  But when I tried it I ran into different problems.

What little documentation I could find on how to use M-x sql-mysql was 
rather incomplete.  It didn't give any information on how to run a 
query. http://www.emacswiki.org/emacs/SqlMode says,

     "Type M-x sql-help RET to read the online help."

so I did that.  The help suggests running:

     M-x sql-mysql

to invoke MySQL, and then says,

    "Once you have the SQLi buffer, you can enter SQL statements in the
    buffer.  The output generated is appended to the buffer and a new
    prompt is generated."

The buffer never displayed a prompt.  I can't click on the items in the 
menubar at the top because I'm connecting via ssh (client is putty), and 
putty doesn't seem to transmit mouse clicks.  So I can't get at the 
"SQL" or "In/Out" menus in Emacs' menubar.

I tried sending a C-c (by typing C-c C-c) to the *SQL* buffer, expecting 
that would cause it to exit, just like a shell buffer.  Much to my 
surprise, IT DISPLAYED THE OUTPUT OF THE QUERY I'D ENTERED before reporting:

     Ctrl-C -- exit!
     Process SQL exited abnormally with code 1

I then noticed that M-x sql-help also says:

    "If you have a really complex SQL statement or if you are writing a
    procedure, you can do this in a separate buffer. Put the new buffer
    in `sql-mode' by calling M-x sql-mode.  The name of this buffer can
    be anything.  The name of the major mode is SQL."

    "In this SQL buffer (SQL mode), you can send the region or the
    entire buffer to the interactive SQL buffer (SQLi mode).  The
    results are appended to the SQLi buffer without disturbing your SQL
    buffer."

So I created a second buffer, named it "my-sql-buffer" and ran M-x 
sql-mode.  When I type the query:

     show tables;

into that buffer and terminate it with RET, nothing happens in the *SQL* 
buffer.  I tried positioning my cursor at the end of the query and 
typing C-c C-c.  The minibuffer at the bottom displayed:

     "Sent string to buffer *SQL*."

but nothing appeared in the *SQL* buffer.  I typed C-c C-c a few more 
times.  Each time the minibufferredisplayed:

     "Sent string to buffer *SQL*."

After typing C-c C-c several times, suddenly output appeared in the 
*SQL* buffer.  It was the output from:

     show tables;

repeated 5 times!  Except the last time stopped in the middle.  This 
behavior suggests that something is buffering the output.  I checked how 
many bytes had been output (C-x h M-C-| wc -c) and it had output 4096 
bytes!  Since 4K is a common buffer size, this confirms my suspicion 
that something is buffering the output.  But I can't figure out what's 
doing the buffering and how to turn the buffering off.

Can anyone help me solve one or more of the following problems:

1. How to run the mysql executable from a bash prompt inside emacs and 
not have it hang when it calls tcsetattr()?

2. How to run M-x sql-mysql, type a query into the *SQL* buffer and 
actually get it to run without making the SQL process exit?

3. How to flush the output to *SQL* after each query when I type a query 
into a second buffer that's in sql-mode?

advTHANKSance for your help.

    Mark Rosenthal
    mbr@arlsoft.com <mailto:mbr@arlsoft.com>




[-- Attachment #2: Type: text/html, Size: 6787 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-02-02 21:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.4.1296574101.31480.help-gnu-emacs@gnu.org>
2011-02-01 15:41 ` Problems trying to use MySQL in conjunction with Emacs rusi
2011-02-02 21:34 ` Tim X
2011-02-01 13:32 MBR

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.