pgwire-lite-rs
A lightweight PostgreSQL wire protocol client library for Rust.
Overview
pgwire-lite provides a simple, efficient interface for executing queries against PostgreSQL-compatible servers, including StackQL and other wire-protocol compatible services.
This crate was created for applications that need a robust, well-tested connection to PostgreSQL-compatible servers without the overhead of a full-featured ORM.
Features
- Simple API - Straightforward query execution with minimal boilerplate
- Robust Error Handling - Comprehensive error information with configurable verbosity
- Flexible Value Types - Easy type conversion between PostgreSQL and Rust types
- SSL/TLS Support - Secure connections with TLS and certificate validation
- Detailed Results - Full access to all aspects of query results including notices
- libpq Foundation - Built on the stable, production-tested libpq C library
Installation
Add this to your Cargo.toml:
[]
= "0.1.0"
Quick Start
The following example connects to a local stackql server used to query cloud providers.
use PgwireLite;
Error Handling
pgwire-lite provides detailed error information and configurable verbosity:
use PgwireLite;
TLS/SSL Support
Secure your connections with TLS:
use PgwireLite;
use env;
Documentation
For more detailed usage examples and API documentation, please visit docs.rs/pgwire-lite.
Building Locally
This project depends on libpq (PostgreSQL client library) which needs to be available at compile time.
# Linux (Ubuntu/Debian)
# macOS
# after installing with Homebrew on macOS, you may need to add libpq to your PATH:
# or for Intel Macs with Homebrew in the default location
# for Apple Silicon Macs, use: echo 'export PATH="/opt/homebrew/opt/libpq/bin:$PATH"' >> ~/.zshrc
# Also set these environment variables for the compiler to find libpq
Building the project
To build locally use:
Testing the project
The tests provided can be performed with a stackql server.
Download
stackqlusing:&&
Without TLS
To test the library with a local server without tls, run the following:
# or with verbose output
RUST_LOG=debug
To run the examples with a local server without tls, use the following:
# or with verbose output
RUST_LOG=debug
With TLS
To test the library with a local server with tls, run the following:
# or with verbose output
RUST_LOG=debug
To run the examples with a local server with tls, use the following:
# or with verbose output
RUST_LOG=debug
Documenting the project
To document the project locally, use:
Other utilities
Other useful cargo utilities include:
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.