Expand description
SAL PostgreSQL Client
This crate provides a PostgreSQL client for interacting with PostgreSQL databases. It offers connection management, query execution, and a builder pattern for flexible configuration.
§Features
- Connection Management: Automatic connection handling and reconnection
- Query Execution: Simple API for executing queries and fetching results
- Builder Pattern: Flexible configuration with authentication support
- Environment Variable Support: Easy configuration through environment variables
- Thread Safety: Safe to use in multi-threaded applications
- PostgreSQL Installer: Install and configure PostgreSQL using nerdctl
- Rhai Integration: Scripting support for PostgreSQL operations
§Usage
use sal_postgresclient::{execute, query, query_one};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Execute a query
let rows_affected = execute("CREATE TABLE users (id SERIAL PRIMARY KEY, name TEXT)", &[])?;
// Query data
let rows = query("SELECT * FROM users", &[])?;
// Query single row
let row = query_one("SELECT * FROM users WHERE id = $1", &[&1])?;
Ok(())
}
Modules§
- rhai
- Rhai wrappers for PostgreSQL client module functions
Structs§
- Postgres
Client Wrapper - Wrapper for PostgreSQL client to handle connection
- Postgres
Config Builder - PostgreSQL connection configuration builder
- Postgres
Installer Config - PostgreSQL installer configuration
- Query
Params - Parameter builder for PostgreSQL queries
Enums§
Functions§
- create_
database - Create a new database in PostgreSQL
- execute
- Execute a query on the PostgreSQL connection
- execute_
sql - Execute a SQL script in PostgreSQL
- execute_
with_ params - Execute a query with the parameter builder
- execute_
with_ pool - Execute a query using the connection pool
- execute_
with_ pool_ params - Execute a query with the parameter builder using the connection pool
- get_
postgres_ client - Get the PostgreSQL client instance
- get_
postgres_ pool - Get the PostgreSQL connection pool instance
- install_
postgres - Install PostgreSQL using nerdctl
- is_
postgres_ running - Check if PostgreSQL is running
- notify
- Send a notification on a channel
- notify_
with_ pool - Send a notification on a channel using the connection pool
- query
- Execute a query on the PostgreSQL connection and return the rows
- query_
one - Execute a query on the PostgreSQL connection and return a single row
- query_
one_ with_ params - Execute a query with the parameter builder and return a single row
- query_
one_ with_ pool - Execute a query using the connection pool and return a single row
- query_
one_ with_ pool_ params - Execute a query with the parameter builder using the connection pool and return a single row
- query_
opt - Execute a query on the PostgreSQL connection and return an optional row
- query_
opt_ with_ params - Execute a query with the parameter builder and return an optional row
- query_
opt_ with_ pool - Execute a query using the connection pool and return an optional row
- query_
opt_ with_ pool_ params - Execute a query with the parameter builder using the connection pool and return an optional row
- query_
with_ params - Execute a query with the parameter builder and return the rows
- query_
with_ pool - Execute a query using the connection pool and return the rows
- query_
with_ pool_ params - Execute a query with the parameter builder using the connection pool and return the rows
- reset
- Reset the PostgreSQL client
- reset_
pool - Reset the PostgreSQL connection pool
- transaction
- Transaction functions for PostgreSQL
- transaction_
with_ pool - Transaction functions for PostgreSQL using the connection pool
- with_
config - Create a new PostgreSQL client with custom configuration
- with_
pool_ config - Create a new PostgreSQL connection pool with custom configuration