| Crates.io | gaussdb-protocol |
| lib.rs | gaussdb-protocol |
| version | 0.1.0 |
| created_at | 2025-06-09 14:12:07.766638+00 |
| updated_at | 2025-06-09 14:12:07.766638+00 |
| description | Low level GaussDB protocol APIs based on PostgreSQL |
| homepage | |
| repository | https://github.com/HuaweiCloudDeveloper/gaussdb-rust |
| max_upload_size | |
| id | 1705974 |
| size | 122,788 |
GaussDB and OpenGauss support for Rust.
A native, synchronous GaussDB client with full PostgreSQL compatibility.
A native, asynchronous GaussDB client with full PostgreSQL compatibility.
Conversions between Rust and GaussDB/PostgreSQL types.
TLS support for gaussdb and tokio-gaussdb via native-tls.
TLS support for gaussdb and tokio-gaussdb via openssl.
This library provides full support for GaussDB's enhanced authentication mechanisms:
use tokio_gaussdb::{NoTls, Error};
#[tokio::main]
async fn main() -> Result<(), Error> {
// Connect to GaussDB with SHA256 authentication
let (client, connection) = tokio_gaussdb::connect(
"host=localhost user=gaussdb password=Gaussdb@123 dbname=postgres port=5433",
NoTls,
).await?;
// Spawn the connection task
tokio::spawn(async move {
if let Err(e) = connection.await {
eprintln!("connection error: {}", e);
}
});
// Execute a simple query
let rows = client.query("SELECT $1::TEXT", &[&"hello world"]).await?;
let value: &str = rows[0].get(0);
println!("Result: {}", value);
Ok(())
}
use tokio_gaussdb::{Config, NoTls};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Configure connection with specific authentication
let mut config = Config::new();
config
.host("localhost")
.port(5433)
.user("gaussdb")
.password("Gaussdb@123")
.dbname("postgres");
let (client, connection) = config.connect(NoTls).await?;
// Handle connection...
tokio::spawn(async move {
if let Err(e) = connection.await {
eprintln!("connection error: {}", e);
}
});
// Your application logic here
Ok(())
}
| Database | Version | Authentication | Status |
|---|---|---|---|
| GaussDB | 2.0+ | SHA256, MD5_SHA256, MD5 | ✅ Full Support |
| OpenGauss | 3.0+ | SHA256, MD5_SHA256, MD5 | ✅ Full Support |
| PostgreSQL | 10+ | SCRAM-SHA-256, MD5 | ✅ Full Support |
| Feature | GaussDB | OpenGauss | PostgreSQL |
|---|---|---|---|
| Basic SQL Operations | ✅ | ✅ | ✅ |
| Transactions | ✅ | ✅ | ✅ |
| Prepared Statements | ✅ | ✅ | ✅ |
| COPY Operations | ✅ | ✅ | ✅ |
| LISTEN/NOTIFY | ⚠️ Limited | ⚠️ Limited | ✅ |
| Binary COPY | ⚠️ Issues | ⚠️ Issues | ✅ |
The test suite requires GaussDB or OpenGauss to be running. The easiest way is with Docker:
Install docker and docker-compose
sudo apt install docker.io docker-composeMake sure your user has Docker permissions
sudo usermod -aG docker $USERgaussdb-rust repodocker-compose up -d
cargo test
docker-compose stop
The test suite supports both GaussDB and OpenGauss environments. Connection strings are automatically configured for:
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
Clone the repository:
git clone https://github.com/HuaweiCloudDeveloper/gaussdb-rust.git
cd gaussdb-rust
Install Rust (if not already installed):
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Run tests:
cargo test
This project is licensed under either of
at your option.
This project is based on the excellent rust-postgres library by Steven Fackler. We extend our gratitude to the original authors and contributors.