[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/emacsql 3511a0df1d 037/427: Add a top-level query function
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/emacsql 3511a0df1d 037/427: Add a top-level query function, emacsql. |
Date: |
Tue, 13 Dec 2022 02:59:25 -0500 (EST) |
branch: elpa/emacsql
commit 3511a0df1d1a19d7be0b2507e16330eff6b12470
Author: Christopher Wellons <wellons@nullprogram.com>
Commit: Christopher Wellons <wellons@nullprogram.com>
Add a top-level query function, emacsql.
---
emacsql.el | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/emacsql.el b/emacsql.el
index 07a2b97901..ebb62d31b8 100644
--- a/emacsql.el
+++ b/emacsql.el
@@ -292,7 +292,7 @@ Each row must be a sequence of values to store into TABLE.
(emacsql--check-error conn)
(emacsql--parse conn))
-;; SQL Expansion Functions
+;; SQL Expansion:
(defvar emacsql-expanders ()
"Alist of all expansion functions.")
@@ -327,6 +327,13 @@ and should return a list of (<string> [arg-pos] ...)."
(:identifier (emacsql-escape (nth i args)))
(:value (emacsql-escape-value (nth i args))))))))
+(defun emacsql (conn sql &optional args)
+ "Send structured SQL expression to CONN with ARGS."
+ (emacsql--clear conn)
+ (emacsql--send conn (apply #'emacsql-format (emacsql-expand sql) args))
+ (emacsql--check-error conn)
+ (emacsql--parse conn))
+
(defun emacsql-var (var)
"Return the index number of VAR, or nil if VAR is not a variable.
A variable is a symbol that looks like $1, $2, $3, etc. A $ means $1."
@@ -346,6 +353,8 @@ KIND should be :value or :identifier."
(:identifier (emacsql-escape thing))
(otherwise thing))))
+;; SQL Expansion Functions:
+
(emacsql-defexpander :select (arg)
"Expands to the SELECT keyword."
(let ((vars ()))
- [nongnu] elpa/emacsql 961c689269 011/427: Rename information to constraints., (continued)
- [nongnu] elpa/emacsql 961c689269 011/427: Rename information to constraints., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql c7a8ef0908 015/427: Rename every emacsql argument to conn., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql d083cbb70e 017/427: Add in-memory database support., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 9091fe8df5 019/427: Rename sqlite-program-name into namespace., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 9c3293c57e 020/427: Add a docstring to emacsql struct., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 178a31d5ca 024/427: Lock in the coding system., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 85076dfe0f 027/427: Flesh out example more., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql c9854331c0 028/427: Add (un)license header., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 896bb7ce52 035/427: Start adding SQL expanders., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 9272d13ace 036/427: Add some tests for the expanders., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 3511a0df1d 037/427: Add a top-level query function, emacsql.,
ELPA Syncer <=
- [nongnu] elpa/emacsql 7e18a43da1 039/427: Add a template example., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 8b2cf8c208 041/427: Fix up :where., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql c92c56ce55 003/427: Add a close buffer sentinel., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 1a84c983cf 013/427: No named results by default., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 76a430032e 014/427: Fix up old test., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 36c6aae4b5 042/427: Drop raw select., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 77ae713186 046/427: Create table expander., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql e859204451 064/427: Flesh out more README., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 35676bb560 065/427: Fix README examples., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 847f3bd87f 078/427: Add new keywords to listing., ELPA Syncer, 2022/12/13