Struct tokio_postgres::Connection [] [src]

pub struct Connection(_);

A connection to a Postgres database.

Methods

impl Connection
[src]

Creates a new connection to a Postgres database.

Most applications can use a URL string in the normal format:

postgresql://user[:password]@host[:port][/database][?param1=val1[[&param2=val2]...]]

The password may be omitted if not required. The default Postgres port (5432) is used if none is specified. The database name defaults to the username if not specified.

To connect to the server via Unix sockets, host should be set to the absolute path of the directory containing the socket file. Since / is a reserved character in URLs, the path should be URL encoded. If the path contains non-UTF 8 characters, a ConnectParams struct should be created manually and passed in. Note that Postgres does not support TLS over Unix sockets.

Execute a sequence of SQL statements.

Statements should be separated by ; characters. If an error occurs, execution of the sequence will stop at that point. This is intended for execution of batches of non-dynamic statements - for example, creation of a schema for a fresh database.

Warning

Prepared statements should be used for any SQL statement which contains user-specified data, as it provides functionality to safely embed that data in the statement. Do not form statements via string concatenation and feed them into this method.

Creates a new prepared statement.

Executes a statement, returning the number of rows modified.

Panics

Panics if the number of parameters provided does not match the number expected.

Executes a statement, returning a stream over the resulting rows.

Panics

Panics if the number of parameters provided does not match the number expected.

Starts a new transaction.

Returns a stream of asynchronus notifications receieved from the server.

Returns information used to cancel pending queries.

Used with the cancel_query function. The object returned can be used to cancel any query executed by the connection it was created from.

Returns the value of the specified Postgres backend parameter, such as timezone or server_version.

Trait Implementations

impl Debug for Connection
[src]

Formats the value using the given formatter.