diff options
author | Dominik Picheta <dominikpicheta@gmail.com> | 2016-01-18 13:34:26 +0000 |
---|---|---|
committer | Dominik Picheta <dominikpicheta@gmail.com> | 2016-01-18 13:34:53 +0000 |
commit | 6ca9e5cbcc940ad86045884840770415d1759f56 (patch) | |
tree | be26d2a1f987c645e075e9cf6fd7aae9c5084ca1 /lib/impure/db_sqlite.nim | |
parent | b0aaeaa43693b31807c3392d296083bc27a5ce62 (diff) | |
download | Nim-6ca9e5cbcc940ad86045884840770415d1759f56.tar.gz |
Improved documentation for all db modules.
Diffstat (limited to 'lib/impure/db_sqlite.nim')
-rw-r--r-- | lib/impure/db_sqlite.nim | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/lib/impure/db_sqlite.nim b/lib/impure/db_sqlite.nim index c0d221a0d..1633d48f7 100644 --- a/lib/impure/db_sqlite.nim +++ b/lib/impure/db_sqlite.nim @@ -10,7 +10,48 @@ ## A higher level `SQLite`:idx: database wrapper. This interface ## is implemented for other databases too. ## -## Example: +## See also: `db_odbc <db_odbc.html>`_, `db_postgres <db_postgres.html>`_, +## `db_mysql <db_mysql.html>`_. +## +## Parameter substitution +## ---------------------- +## +## All ``db_*`` modules support the same form of parameter substitution. +## That is, using the ``?`` (question mark) to signify the place where a +## value should be placed. For example: +## +## .. code-block:: Nim +## sql"INSERT INTO myTable (colA, colB, colC) VALUES (?, ?, ?)" +## +## Examples +## -------- +## +## Opening a connection to a database +## ================================== +## +## .. code-block:: Nim +## import db_sqlite +## let db = open("localhost", "user", "password", "dbname") +## db.close() +## +## Creating a table +## ================ +## +## .. code-block:: Nim +## db.exec(sql"DROP TABLE IF EXISTS myTable") +## db.exec(sql("""CREATE TABLE myTable ( +## id integer, +## name varchar(50) not null)""")) +## +## Inserting data +## ============== +## +## .. code-block:: Nim +## db.exec(sql"INSERT INTO myTable (id, name) VALUES (0, ?)", +## "Jack") +## +## Larger example +## ============== ## ## .. code-block:: nim ## |