[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/emacsql 7e18a43da1 039/427: Add a template example.
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/emacsql 7e18a43da1 039/427: Add a template example. |
Date: |
Tue, 13 Dec 2022 02:59:26 -0500 (EST) |
branch: elpa/emacsql
commit 7e18a43da17bf0df75f6ec077250b87671f7e797
Author: Christopher Wellons <wellons@nullprogram.com>
Commit: Christopher Wellons <wellons@nullprogram.com>
Add a template example.
---
README.md | 8 +++++++-
emacsql.el | 17 +++++++++++------
2 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/README.md b/README.md
index f323cf7f88..cac2ff25a4 100644
--- a/README.md
+++ b/README.md
@@ -29,8 +29,14 @@ Requires Emacs 24 or later.
["Susan" 1001 64000.0])
;; Query the database for results:
-(emacsql db [:select [name id] :from employees :where (> salary 60000)])
+(emacsql db [:select [name id] :from employees :where (> salary 62000)])
;; => (("Susan" 1001))
+
+;; Queries can be templates using $1, $2, etc.:
+(emacsql db
+ [:select [name id] :from employees :where (> salary $1)]
+ 50000)
+;; => (("Jeff" 1000) ("Susan" 1001))
```
## Limitations
diff --git a/emacsql.el b/emacsql.el
index ef6a7a0188..ae596c15bd 100644
--- a/emacsql.el
+++ b/emacsql.el
@@ -26,26 +26,31 @@
;; Table identifiers can be any lisp object: string, symbol, etc. I
;; suggest using a symbol. Use `emacsql-create' to create a table.
-;; (emacsql-create db :employees [name id salary])
+;; (emacsql-create db 'employees [name id salary])
;; Column constraints can optionally be provided.
-;; (emacsql-create db :employees [(name text) (id integer) (salary real)])
+;; (emacsql-create db 'employees [name (id integer) (salary real)])
;; Insert values into a table with `emacsql-insert'.
-;; (emacsql-insert db :employees ["Jeff" 1000 60000.0]
+;; (emacsql-insert db 'employees ["Jeff" 1000 60000.0]
;; ["Susan" 1001 64000.0])
;; Currently all actions are synchronous and Emacs will block until
;; SQLite has indicated it is finished processing the last command.
-;; High-level query construction is still a work-in-progress:
+;; Query the database for results:
-;; (emacsql-select-raw db (concat "SELECT name, id FROM ':employees' "
-;; "WHERE salary > 60000;"))
+;; (emacsql db [:select [name id] :from employees :where (> salary 60000)])
;; ;; => (("Susan" 1001))
+;; Queries can be templates using $1, $2, etc.:
+;; (emacsql db
+;; [:select [name id] :from employees :where (> salary $1)]
+;; 50000)
+;; ;; => (("Jeff" 1000) ("Susan" 1001))
+
;; Limitations:
;; Due to limitations of the SQLite command line program, emacsql is
- [nongnu] elpa/emacsql c7a8ef0908 015/427: Rename every emacsql argument to conn., (continued)
- [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, 2022/12/13
- [nongnu] elpa/emacsql 7e18a43da1 039/427: Add a template example.,
ELPA Syncer <=
- [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
- [nongnu] elpa/emacsql a9b9d6bfc8 083/427: Fix typo in README., ELPA Syncer, 2022/12/13