Permalink
Browse files

README: Added documentation about the SQLite database access.

  • Loading branch information...
1 parent 18c2e1d commit c875993c375fde32676f284d6a181e64a9f1d5f1 @sigurdmeldgaard sigurdmeldgaard committed Sep 20, 2010
Showing with 29 additions and 7 deletions.
  1. +29 −7 README.markdown
View
36 README.markdown
@@ -2,7 +2,8 @@
======================================================
`yst` is a tool for generating a static website by filling [string
-template][]s with data taken from [YAML][] or [CSV][] text files. This approach
+template][]s with data taken from [YAML][] or [CSV][] text files or
+[SQLite3][] file based databases. This approach
combines the speed, security, and ease of deployment of a static
website with the flexibility and maintainability of a dynamic site that
separates presentation and data.
@@ -221,20 +222,26 @@ Subtrees can contain other subtrees. Just be consistent about indentation.
### The `data` field
-The `data` field in `index.yaml` can populate any number of stringtemplate
-attributes with data from YAML or CSV files. The syntax is easiest to
-explain by example (note that the keywords do not have to be in ALL CAPS,
-although they may, and the query doesn't have to end with a semicolon,
-though it may):
+The `data` field in `index.yaml` can populate any number of
+stringtemplate attributes with data from YAML or CSV files or SQLite3
+databases. The syntax is easiest to explain by example (note that the
+keywords do not have to be in ALL CAPS, although they may, and the
+query doesn't have to end with a semicolon, though it may):
data:
events: from events.yaml order by date desc group by title then location
people: from people.csv order by birthday then lastname where
birthstate = 'CA' limit 5
+ beststudents: from students.sqlite
+ query "select * from students where grade > 5"
+ order by name
First we have the name of the stringtemplate attribute to be populated
(say, `events`). Then, after the colon, we have the data source
-(`events.yaml`) followed by one or more *transformations*, which will
+(`events.yaml`). If the data source is an SQLite3 database, it should be
+followed by a query that is a quoted string.
+
+The data source is followed by one or more *transformations*, which will
be applied in order. Here are the possible transformations. In
what follows, brackets denote an optional component, `|` denotes
alternatives, and `*` indicates that the component may be repeated
@@ -434,6 +441,20 @@ database, you can use a query like this to get the CSV:
(Thanks to
<http://www.terminally-incoherent.com/blog/2006/07/20/dump-mysql-table-into-csv-file/>.)
+### Using a SQLite database as data source
+
+You can also get the data directly from a database. Just give the file
+name from the database followed by a query quoted in "'s
+
+In this way you can do joins and other advanced operations on your
+data before handing them over to yst:
+
+ data:
+ meetings : FROM data.sqlite
+ QUERY "select * from meetings
+ left outer join persons
+ on meetings.speaker = persons.name"
+
### Using HTML in the templates
Markdown allows raw HTML to be used, so you can embed HTML in templates.
@@ -524,6 +545,7 @@ If you find a bug, please report it using
[string template]: http://www.stringtemplate.org/
[YAML]: http://www.yaml.org/
[CSV]: http://en.wikipedia.org/wiki/Comma-separated_values
+[SQLite3]: http://www.sqlite.org/
[cabal install]: http://hackage.haskell.org/trac/hackage/wiki/CabalInstall
[Haskell platform]: http://hackage.haskell.org/platform/
[markdown]: http://daringfireball.com/markdown

0 comments on commit c875993

Please sign in to comment.