Giter Site home page Giter Site logo

Comments (5)

tarsius avatar tarsius commented on June 26, 2024

EmacSQL is not intended to be used as a general-purpose database interface. See https://github.com/magit/emacsql#faq.

from emacsql.

agzam avatar agzam commented on June 26, 2024

I understand that, and I guess my question is a bit general. I wonder if this lib can be (should be) used as a default driver for querying SQL DBs, in my case, specifically sqlite.

The built-in Emacs 29 lib makes querying sqlite a breeze.

What's the recommended/idiomatic way of doing it for previous versions of Emacs?

I'm a bit lost trying to understand how emacsql-sqlite, emacssql-sqlite-builtin, emacssql-sqlite-module are related.

Also, I recently set (setq forge-database-connector 'sqlite-builtin), but got surprised that I still need to install emacsql-sqlite-builtin. I'm using the latest Emacs built from --head, I thought I don't need another package.

Is there a good place to start reading to understand how these packages are related and work with each other?

And again, if someone points to a simple snippet example that queries (any arbitrary) sqlite db in a way that works in both Emacs 29 and older versions - that would be awesome.

from emacsql.

agzam avatar agzam commented on June 26, 2024

I guess, I'm just gonna use sqlite.el

from emacsql.

tarsius avatar tarsius commented on June 26, 2024

I understand that, and I guess my question is a bit general. I wonder if this lib can be (should be) used as a default driver for querying SQL DBs, in my case, specifically sqlite.

Every value read from the database is passed through read (except NULL). Unless the database was created using EmacSQL and is only accessed through that, then it is almost certain that read will throw an error for some values. That's the cause of the error in your case.

The built-in Emacs 29 lib makes querying sqlite a breeze.

What's the recommended/idiomatic way of doing it for previous versions of Emacs?

https://github.com/pekingduck/emacs-sqlite3-api works very similar to the new built-in support, which was inspired by the former.

I'm a bit lost trying to understand how emacsql-sqlite, emacssql-sqlite-builtin, emacssql-sqlite-module are related.

  • emacsql-sqlite is the old backend that uses a custom binary.
  • emacssql-sqlite-builtin uses the new built-in support and is the future.
  • emacssql-sqlite-module is as fast and reliable as the new built-in support, but can be used when stuck on an older Emacs release

Users can choose which backend they want to use, but third-party packages need some boilerplate to actually allow that (see code involving forge-database-connector for an example).

Also, I recently set (setq forge-database-connector 'sqlite-builtin), but got surprised that I still need to install emacsql-sqlite-builtin. I'm using the latest Emacs built from --head, I thought I don't need another package.

By using that setting you are telling EmacSQL that you want to use the backend provided by the emacsql-sqlite-builtin package, which is a thin wrapper around the new built-in support.

For the time being third-party packages still declare that they depend on emacsql-sqlite, which was the only SQLite backend that existed when they added that dependency. Unfortunately package.el/elpa does not allow declaring a dependency such as (or emacsql-sqlite emacssql-sqlite-builtin emacssql-sqlite-module).

In the future all these backends (or just the two new ones) might be put back into the emacsql package to make things easier. Other approaches are also still on the table. I won't work on that until January or maybe February.

Is there a good place to start reading to understand how these packages are related and work with each other?

Beyond what I wrote above, I don't think so. I know there is work to be done here, but until I have decided how to do things going forward, I won't write any documentation that might very soon become obsolete.

And again, if someone points to a simple snippet example that queries (any arbitrary) sqlite db in a way that works in both Emacs 29 and older versions - that would be awesome.

It probably would not be hard to write a small wrapper that abstracts the new built-in support and the very similar api provided by
https://github.com/pekingduck/emacs-sqlite3-api.

I guess, I'm just gonna use sqlite.el

A file by that name is part of the new builtin support in Emacs. There also exists a file by the same name in https://gitlab.com/cnngimenez/sqlite.el. To use the latter, you would have to rename it and possibly some functions it defines to remove the conflict.

from emacsql.

agzam avatar agzam commented on June 26, 2024

A few things I kinda guessed (even before you told them), but now it is all clear. Thank you for the detailed explanation.

from emacsql.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.