[−][src]Struct tiberius::Client
Client
is the main entry point to the SQL Server, providing query
execution capabilities.
A Client
is created using the ClientBuilder
, defining the needed
connection options and capabilities.
let mut builder = Client::builder(); builder.host("0.0.0.0"); builder.port(1433); builder.authentication(AuthMethod::sql_server("SA", "<Mys3cureP4ssW0rD>")); // Client is ready to use. let mut conn = builder.build().await?;
Implementations
impl Client
[src]
pub fn builder() -> ClientBuilder
[src]
Starts an instance of ClientBuilder
for specifying the connect
options.
pub async fn execute<'a, 'b>(
&'a mut self,
query: impl Into<Cow<'b, str>>,
params: &'b [&'b dyn ToSql]
) -> Result<ExecuteResult> where
'a: 'b,
[src]
&'a mut self,
query: impl Into<Cow<'b, str>>,
params: &'b [&'b dyn ToSql]
) -> Result<ExecuteResult> where
'a: 'b,
Executes SQL statements in the SQL Server, returning the number rows
affected. Useful for INSERT
, UPDATE
and DELETE
statements.
The query
can define the parameter placement by annotating them with
@PN
, where N is the index of the parameter, starting from 1
.
let results = conn .execute( "INSERT INTO ##Test (id) VALUES (@P1), (@P2), (@P3)", &[&1i32, &2i32, &3i32], ) .await?;
See the documentation for the resulting ExecuteResult
on how to
handle the results correctly.
pub async fn query<'a, 'b>(
&'a mut self,
query: impl Into<Cow<'b, str>>,
params: &'b [&'b dyn ToSql]
) -> Result<QueryResult<'a>> where
'a: 'b,
[src]
&'a mut self,
query: impl Into<Cow<'b, str>>,
params: &'b [&'b dyn ToSql]
) -> Result<QueryResult<'a>> where
'a: 'b,
Executes SQL statements in the SQL Server, returning resulting rows.
Useful for SELECT
statements.
The query
can define the parameter placement by annotating them with
@PN
, where N is the index of the parameter, starting from 1
.
let rows = conn .query( "SELECT @P1, @P2, @P3", &[&1i32, &2i32, &3i32], ) .await?;
See the documentation for the resulting QueryResult
on how to
handle the results correctly.
Auto Trait Implementations
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,