Struct query_builder::InsertQuery
[−]
[src]
pub struct InsertQuery<'a> { pub values: BTreeMap<&'a str, Value<'a>>, // some fields omitted }
Struct representing an SQL Insert Statement
Creating a query that works requires at least to function calls.
Examples
use query_builder::{InsertQuery, Value}; // construct the InsertQuery to insert into table 'users' let mut q = InsertQuery::into("users"); // add the value 'jonathan' to be added into the row 'name' q.values.insert("name", Value::Varchar("jonathan")); assert_eq!(q.as_string(), "INSERT INTO users(name) VALUES('jonathan')");
Fields
values: BTreeMap<&'a str, Value<'a>>
A map of the values to inserted into the table. The map is intended to be <row, value>
Methods
impl<'a> InsertQuery<'a>
[src]
pub fn into(table: &'a str) -> InsertQuery<'a>
[src]
Creates a new InsertQuery
that puts data into table
.
pub fn as_string(&self) -> String
[src]
Returns a String
that represents the InsertQuery
in a valid SQL statement
Example
use query_builder::{Value, InsertQuery}; let mut q = InsertQuery::into("users"); q.values.insert("name", Value::Varchar("greg")); assert_eq!(q.as_string(), "INSERT INTO users(name) VALUES('greg')")
Trait Implementations
impl<'a> Debug for InsertQuery<'a>
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl<'a> Display for InsertQuery<'a>
[src]
fn fmt(&self, f: &mut Formatter) -> FormatResult
[src]
Formats the value using the given formatter. Read more