From 14c0c64c5986df2f163d7de0ede565f5bd81a9f1 Mon Sep 17 00:00:00 2001 From: Araq Date: Mon, 18 Jan 2016 14:54:50 +0100 Subject: [PATCH] Merge branch 'devel' of https://github.com/nim-lang/Nim into devel --- src/db_mysql.nim | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/src/db_mysql.nim b/src/db_mysql.nim index 170fee8b87..1b7f1de617 100644 --- a/src/db_mysql.nim +++ b/src/db_mysql.nim @@ -10,7 +10,49 @@ ## A higher level `mySQL`:idx: database wrapper. The same interface is ## implemented for other databases too. ## -## Example: +## See also: `db_odbc `_, `db_sqlite `_, +## `db_postgres `_. +## +## 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_mysql +## 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, ?)", +## "Dominik") +## +## Larger example +## ============== ## ## .. code-block:: Nim ##