[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/emacsql 730e4d882a 235/427: Fix up the README.
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/emacsql 730e4d882a 235/427: Fix up the README. |
Date: |
Tue, 13 Dec 2022 02:59:47 -0500 (EST) |
branch: elpa/emacsql
commit 730e4d882a1be19a88603b428989e18647da6ab8
Author: Christopher Wellons <wellons@nullprogram.com>
Commit: Christopher Wellons <wellons@nullprogram.com>
Fix up the README.
---
README.md | 62 ++++++++++++++++++++++++++++++++++++--------------------------
1 file changed, 36 insertions(+), 26 deletions(-)
diff --git a/README.md b/README.md
index 0a464bff27..088d6d0110 100644
--- a/README.md
+++ b/README.md
@@ -19,8 +19,9 @@ database.
This package includes custom native binaries for communicating with a
SQLite database. When linked with GNU Readline, or when run in
Windows, the official sqlite3 command shell is incapable of correct
-interaction. If your package depends on Emacsql it also means you
-don't have to rely on the user having particular software installed.
+interaction. If your own package depends on Emacsql as a database it
+also means you don't have to rely on the user having particular
+software installed.
Requires Emacs 24 or later.
@@ -36,7 +37,7 @@ test suite from the Makefile.
(defvar db (emacsql-connect "~/company.db"))
;; Create a table. Table and column identifiers are symbols.
-(emacsql db [:create-table people [name id salary]])
+(emacsql db [:create-table people ([name id salary])])
;; Or optionally provide column constraints.
(emacsql db [:create-table people
@@ -117,11 +118,11 @@ several operators are special.
The `<=` and `>=` operators accept 2 or 3 operands, transforming into
a SQL `_ BETWEEN _ AND _` operator as appropriate.
-For function-like "operators" like `count` and `ave` use the `funcall`
+For function-like "operators" like `count` and `max` use the `funcall`
"operator."
```el
-[:select (funcall ave age) :from people]
+[:select (funcall max age) :from people]
```
Inside expressions, Emacsql cannot tell the difference between symbol
@@ -165,42 +166,51 @@ Emacsql statement are literally just that: lisp keywords.
Emacsql only
understands a very small amount of SQL's syntax. The compiler follows
some simple rules to convert an s-expression into SQL.
- * All prepared statements are vectors.
+#### All prepared statements are vectors.
A prepared s-expression statement is a vector beginning with a keyword
-followed by a series of keywords and special values.
+followed by a series of keywords and special values. This includes
+most kinds of sub-queries.
```el
[:select ... :from ...]
+[:select tag :from tags
+ :where (in tag [:select ...])]
```
- * Keywords are split and capitalized.
+#### Keywords are split and capitalized.
Dashes are converted into spaces and the keyword gets capitalized. For
example, `:if-not-exists` becomes `IF NOT EXISTS`. How you choose to
combine keywords is up to your personal taste (e.g. `:drop :table` vs.
`:drop-table`).
- * Standalone symbols are identifiers.
+#### Standalone symbols are identifiers.
Emacsql doesn't know what symbols refer to identifiers and what
symbols should be treated as values. Use quotes to mark a symbol as a
-value. For example, `people` here will become an identifier.
+value. For example, `people` here will be treated as an identifier.
```el
[:insert-into people :values ...]
```
- * Row-oriented information is stored as vectors.
+#### Row-oriented information is always represented as vectors.
-This includes rows being inserted and sets of columns. If you're
-talking about a raw, put it in a vector.
+This includes rows being inserted, and sets of columns in a query. If
+you're talking about a row-like thing then put it in a vector.
```el
[:select [id name] :from people]
```
- * Lists are treated as expressions.
+Note that `*` is actually a SQL keyword, so don't put it in a vector.
+
+```el
+[:select * :from ...]
+```
+
+#### Lists are treated as expressions.
This is true even within row-oriented vectors.
@@ -209,30 +219,30 @@ This is true even within row-oriented vectors.
[:select [(/ seconds 60) count] :from ...]
```
-Some things that are are traditionally keywords, particularly those
-that are mixed in with expressions, have been converted into
-operators.
+Some things that are traditionally keywords -- particularly those that
+are mixed in with expressions -- have been converted into operators
+(`AS`, `ASC`, `DESC`).
```el
-[... :order-by [(asc b), (desc a)]] ; "ORDER BY b ASC, a DESC"
+[... :order-by [(asc b), (desc a)]] ; "ORDER BY b ASC, a DESC"
+[:select p:name :from (as people p)] ; "SELECT p.name FROM people AS p"
```
- * The `:values` keyword is special.
+#### The `:values` keyword is special.
What follows `:values` is always treated like a vector or list of
-vectors. Normally this would appear to be a column reference.
+vectors. Normally this sort of thing would appear to be a column
+reference.
```el
[... :values [1 2 3]]
[... :values ([1 2 3] [4 5 6])] ; insert multiple rows
```
- * Schemas are always lists at the top level.
+#### A list whose first element is a vector is a table schema.
-This is to distinguish schemas from everything else. They are lists
-whose first element is a vector (column specifications). With the
-exception of what follows `:values`, nothing else would be shaped like
-this.
+This is to distinguish schemas from everything else. With the
+exception of what follows `:values`, nothing else is shaped like this.
```el
[:create-table people ([(id :primary-key) name])]
@@ -261,7 +271,7 @@ When combined with `:values`, the vector type can refer to
lists of
rows.
```el
-(emacsql db [:insert-into people :values $v1]
+(emacsql db [:insert-into favorite-characters :values $v1]
'([0 "Calvin"] [1 "Hobbes"] [3 "Susie"]))
```
- [nongnu] elpa/emacsql 03aebdecd1 160/427: Rename :log option to :debug., (continued)
- [nongnu] elpa/emacsql 03aebdecd1 160/427: Rename :log option to :debug., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql bb221f6134 161/427: Drop .print command flushing., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 72b34f6522 173/427: Add some more autoloading., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 3229cd41af 180/427: Change the requirements for front-end implementations., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 431a3b325f 200/427: Toss "reap" and switch to new finalize with Cask., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql ed86b098ce 197/427: Add prefix arg to emacsql-show-last-sql., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 027c5df94e 209/427: Organize all the keywords in the README., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 1ebbc22411 212/427: Disable undo in process buffers., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 5bef799b6b 220/427: Make some tweaks to accommodate Windows., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 0cb9e47d24 227/427: Test all available backends., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 730e4d882a 235/427: Fix up the README.,
ELPA Syncer <=
- [nongnu] elpa/emacsql 4b45472ffa 240/427: Don't copy the binary every time., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql c89ccf82df 241/427: Make a reconnect generic method., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 159195690d 245/427: Include bin/ in the package., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql f98ee5e7cd 246/427: Use no-undo buffers., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 4b58a6717e 250/427: Don't use temporary tables in foreign key test., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 462d1f1b31 252/427: Fix stupid backslash escape mode in MySQL., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql b0f0d3085d 258/427: Get OS tuple from Emacs., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 1b5891298a 255/427: Officially add MySQL to unit testing., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 127bb98df2 264/427: Set coding system to utf-8-auto for sqlite., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 933e6f109a 263/427: Clean up for easier cross-compilation., ELPA Syncer, 2022/12/13