[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bypassing the prompts in M-x sql-sqlite

From: Eduardo Ochs
Subject: Bypassing the prompts in M-x sql-sqlite
Date: Sat, 29 Oct 2022 10:38:00 -0300

Hi all,

this is - or should be - a very basic question about sql.el...
Let me start by some context.

1. Some context
A person who has never used SQL in her life, but who knows this,

can have a very quick introduction to how to use sqlite - in a very
primitive way - by just running this, by typing <f8> on each line:

• (eepitch-shell)
• (eepitch-kill)
• (eepitch-shell)
rm -v   /tmp/music.sqlitedb
sqlite3 /tmp/music.sqlitedb
create table albums (
  artist text,
  album  text
.dump albums
insert into albums (artist, album) values("Hugo Largo", "Drum");
insert into albums (artist, album) values("Medicine","Her Highness");
insert into albums (artist, album) values("Pink Industry","Retrospective");
insert into albums (artist, album) values("David Bowie", "Low");
.dump albums

The next step is to show her how to use sql.el. This

  M-x sql-sqlite RET /tmp/music.sqlitedb RET

creates a buffer called "*SQL: SQLite*" in sql-interactive-mode mode.
The comments at the top of sql.el say:

  This file provides a sql-mode and a sql-interactive-mode.  The
  original goals were two simple modes providing syntactic
  highlighting.  The interactive mode had to provide a command-line
  history; the other mode had to provide "send region/buffer to SQL
  interpreter" functions.  "simple" in this context means easy to
  use, easy to maintain and little or no bells and whistles.  This
  has changed somewhat as experience with the mode has accumulated.

It should be possible to have both methods of sending commands to
"*SQL: SQLite*" available at the same time - eepitch-line and

2. The question
How do I write a sexp that does the same as

  M-x sql-sqlite RET /tmp/music.sqlitedb RET

when the SQL buffer doesn't exist, and the same as M-x sql-sqlite RET
when the SQL buffer already exists? I am probably misreading the code
in sql.el and, ahem, mislooking some important things, because all my
attempts to write code that bypasses the prompts have failed...

  Thanks in advance! =)
    Eduardo Ochs

reply via email to

[Prev in Thread] Current Thread [Next in Thread]