Add params/named_params macro, and expose ToSql from top level

This commit is contained in:
Thom Chiovoloni
2019-01-29 15:33:57 -08:00
parent 18b8c390ab
commit d7c8d43fb4
2 changed files with 106 additions and 7 deletions

View File

@@ -112,6 +112,17 @@ impl<'conn> Statement<'conn> {
/// }
/// ```
///
/// Note, the `named_params` macro is provided for syntactic convenience, and
/// so the above example could also be written as:
///
/// ```rust,no_run
/// # use rusqlite::{Connection, Result, named_params};
/// fn insert(conn: &Connection) -> Result<usize> {
/// let mut stmt = conn.prepare("INSERT INTO test (name) VALUES (:name)")?;
/// stmt.execute_named(named_params!{":name": "one"})
/// }
/// ```
///
/// # Failure
///
/// Will return `Err` if binding parameters fails, the executed statement
@@ -205,6 +216,21 @@ impl<'conn> Statement<'conn> {
/// }
/// ```
///
/// Note, the `named_params!` macro is provided for syntactic convenience, and
/// so the above example could also be written as:
///
/// ```rust,no_run
/// # use rusqlite::{Connection, Result, named_params};
/// fn query(conn: &Connection) -> Result<()> {
/// let mut stmt = conn.prepare("SELECT * FROM test where name = :name")?;
/// let mut rows = stmt.query_named(named_params!{ ":name": "one" })?;
/// while let Some(row) = rows.next() {
/// // ...
/// }
/// Ok(())
/// }
/// ```
///
/// # Failure
///
/// Will return `Err` if binding parameters fails.