PgwireLite

Struct PgwireLite 

Source
pub struct PgwireLite { /* private fields */ }
Expand description

Main client for interacting with PostgreSQL-compatible servers.

This struct provides the core functionality for establishing connections and executing queries against a PostgreSQL-compatible server.

Implementations§

Source§

impl PgwireLite

Source

pub fn new( hostname: &str, port: u16, use_tls: bool, verbosity: &str, ) -> Result<Self, Box<dyn Error>>

Creates a new PgwireLite client with the specified connection parameters.

§Arguments
  • hostname - The hostname or IP address of the PostgreSQL server
  • port - The port number the PostgreSQL server is listening on
  • use_tls - Whether to use TLS encryption for the connection
  • verbosity - Error/notice verbosity level, one of: “terse”, “default”, “verbose”, “sqlstate”
§Returns

A Result containing the new PgwireLite instance or an error

§Example
use pgwire_lite::PgwireLite;

let client = PgwireLite::new("localhost", 5432, false, "default")
    .expect("Failed to create client");
Source

pub fn libpq_version(&self) -> String

Returns the version of the underlying libpq library.

§Returns

A string representing the version in the format “major.minor.patch”

Source

pub fn verbosity(&self) -> String

Returns the current verbosity setting.

§Returns

A string representation of the current verbosity level

Source

pub fn query(&self, query: &str) -> Result<QueryResult, Box<dyn Error>>

Executes a SQL query and returns the results.

This method creates a fresh connection for each query, executes the query, and processes the results. It handles all aspects of connection management and error handling.

§Arguments
  • query - The SQL query to execute
§Returns

A Result containing a QueryResult with the query results or an error

§Example
use pgwire_lite::PgwireLite;

let client = PgwireLite::new("localhost", 5444, false, "default")
    .expect("Failed to create client");
     
let result = client.query("SELECT 1 as value")
    .expect("Query failed");
     
println!("Number of rows: {}", result.row_count);

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.