SQLite-el

sqlite.el is a simple SqliteInterface for connecting and retrieving information using the SQLite program through Elisp programming. It is not intended as a user interface, for that see SqlMode.

It has been created as a temporary solution because the JasonFruit’s script is not available through the link given. As his script, this is based on the code founded at the third item in this page: http://mysite.verizon.net/mbcladwell/.

You can download it from Github: https://gitlab.com/cnngimenez/sqlite.el .

Features

This interface has the following features:

Problems

The library had some problems that it has been corrected:

  1. Corrected! The first query gives you the sqlite welcome and version. This is the first text that sqlite program prompts when you connect.
  2. Corrected! There is only one connection, you can’t mannage more!
  3. The output buffer has not been erased, just hidden.
  4. Process buffers is created for each time you call sqlite-init.
  5. Corrected! Error manipulation is still under development.

API Elements

The API works with three basic commands. We use a number called “descriptor” for uniquely referencing each connection. The commands mysql-init give you a unique descriptor.

You can find the following elements:

Variables:

You may find this variable important, but for working is unnecessary.

Functions:

Usage

Just start the program using sqlite-init, and then query what you want calling sqlite-query. When you finish using your SQLite database, close the program with sqlite-bye

An example of usage:

    (require 'sqlite)
    
    (let ((descriptor (sqlite-init "~/mydb.sqlite")))
        (setq res (sqlite-query descriptor "SELECT * FROM persona"))
        (sqlite-bye descriptor)
        res
     )

This example will try to open mydb.sqlite in your home directory and send the SQL query. You can also send (sqlite-query descriptor ".tables") for listing the tables.

You can replace the ‘descriptor’ temporal variable with the number when you are trying this in the scratch buffer.


SQLite CategorySql