[][src]Struct sqlite3builder::Sqlite3Builder

pub struct Sqlite3Builder { /* fields omitted */ }

Builder stored info

Methods

impl Sqlite3Builder[src]

pub fn select_from(table: &str) -> Self[src]

Create SELECT request. You may specify comma separted list of tables.

use crate::Sqlite3Builder;

let sql = Sqlite3Builder::select_from("books")
    .field("title")
    .field("price")
    .and_where("price > 100")
    .and_where("title LIKE 'Harry Potter%'")
    .sql();

assert_eq!(Some("SELECT title, price FROM books WHERE (price > 100) AND (title LIKE 'Harry Potter%');"), &sql.as_ref());

pub fn insert_into(table: &str) -> Self[src]

Create INSERT request.

use crate::Sqlite3Builder;

let sql = Sqlite3Builder::insert_into("books")
    .field("title")
    .field("price")
    .values(&[&quote("In Search of Lost Time"), "150"])
    .values(&["'Don Quixote', 200"])
    .sql();

assert_eq!(Some("INSERT INTO books (title, price) VALUES ('In Search of Lost Time', 150), ('Don Quixote', 200);"), &sql.as_ref());

pub fn update_table(table: &str) -> Self[src]

Create UPDATE request.

use crate::Sqlite3Builder;

let sql = Sqlite3Builder::update_table("books")
    .set("price", "price + 10")
    .sql();

assert_eq!(Some("UPDATE books SET price = price + 10;"), &sql.as_ref());

pub fn delete_from(table: &str) -> Self[src]

Create DELETE request.

use crate::Sqlite3Builder;

let sql = Sqlite3Builder::delete_from("books")
    .and_where("price > 100")
    .sql();

assert_eq!(Some("DELETE FROM books WHERE price > 100;"), &sql.as_ref());

pub fn join(
    &mut self,
    table: &str,
    operator: Option<&str>,
    constraint: Option<&str>
) -> &mut Self
[src]

Join with table.

use crate::Sqlite3Builder;

let sql = Sqlite3Builder::select_from("books AS b")
    .field("b.title")
    .field("s.total")
    .join("shops AS s", Some("LEFT OUTER"), Some("ON b.id = s.book"))
    .sql();

assert_eq!(Some("SELECT b.title, s.total FROM books AS b LEFT OUTER JOIN shops AS s ON b.id = s.book;"), &sql.as_ref());

pub fn distinct(&mut self) -> &mut Self[src]

Set DISTINCT for fields.

use crate::Sqlite3Builder;

let sql = Sqlite3Builder::select_from("books")
    .distinct()
    .field("price")
    .sql();

assert_eq!(Some("SELECT DISTINCT price FROM books;"), &sql.as_ref());

pub fn fields(&mut self, fields: &[&str]) -> &mut Self[src]

Add fields.

use crate::Sqlite3Builder;

let sql = Sqlite3Builder::select_from("books")
    .fields(&["title", "price"])
    .sql();

assert_eq!(Some("SELECT title, price FROM books;"), &sql.as_ref());

pub fn set_fields(&mut self, fields: &[&str]) -> &mut Self[src]

Replace fields

pub fn field(&mut self, field: &str) -> &mut Self[src]

Add field

pub fn set_field(&mut self, field: &str) -> &mut Self[src]

Replace fields with choosed one

pub fn set(&mut self, field: &str, value: &str) -> &mut Self[src]

Add SET part (for UPDATE)

pub fn values(&mut self, values: &[&str]) -> &mut Self[src]

Add VALUES part (for INSERT)

pub fn group_by(&mut self, field: &str) -> &mut Self[src]

Add GROUP BY part

pub fn having(&mut self, cond: &str) -> &mut Self[src]

Add HAVING condition

pub fn and_where(&mut self, cond: &str) -> &mut Self[src]

Add WHERE condition

pub fn and_where_eq(&mut self, field: &str, value: &str) -> &mut Self[src]

Add WHERE condition for equal parts

pub fn order_by(&mut self, field: &str, desc: bool) -> &mut Self[src]

Add ORDER BY

pub fn order_asc(&mut self, field: &str) -> &mut Self[src]

Add ORDER BY ASC

pub fn order_desc(&mut self, field: &str) -> &mut Self[src]

Add ORDER BY DESC

pub fn limit(&mut self, limit: usize) -> &mut Self[src]

Set LIMIT

pub fn offset(&mut self, offset: usize) -> &mut Self[src]

Set OFFSET

pub fn sql(&self) -> Result<String, Box<dyn Error>>[src]

Build complete SQL command

pub fn subquery(&self) -> Result<String, Box<dyn Error>>[src]

Build subquery SQL command

pub fn subquery_as(&self, name: &str) -> Result<String, Box<dyn Error>>[src]

Build named subquery SQL command

pub fn exec(
    &self,
    conn: &PooledConnection<SqliteConnectionManager>
) -> Result<(), Box<dyn Error>>
[src]

Execute request

pub fn get(
    &self,
    conn: &PooledConnection<SqliteConnectionManager>
) -> Result<Vec<Vec<JValue>>, Box<dyn Error>>
[src]

Execute and return all data

pub fn get_row(
    &self,
    conn: &PooledConnection<SqliteConnectionManager>
) -> Result<Vec<JValue>, Box<dyn Error>>
[src]

Execute and return first row

pub fn get_value(
    &self,
    conn: &PooledConnection<SqliteConnectionManager>
) -> Result<JValue, Box<dyn Error>>
[src]

Execute and return first value

pub fn get_int(
    &self,
    conn: &PooledConnection<SqliteConnectionManager>
) -> Result<i64, Box<dyn Error>>
[src]

Execute and return first integer value

pub fn get_str(
    &self,
    conn: &PooledConnection<SqliteConnectionManager>
) -> Result<String, Box<dyn Error>>
[src]

Execute and return first string value

pub fn get_cursor<'a>(
    &'a self,
    conn: &'a PooledConnection<SqliteConnectionManager>
) -> Result<Cursor<'a>, Box<dyn Error>>
[src]

Get cursor for request

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.