This is an automated email from the ASF dual-hosted git repository.
xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git
The following commit(s) were added to refs/heads/main by this push:
new e2f360473 docs: Add an example for PostgreSQL service (#2847)
e2f360473 is described below
commit e2f360473a1734639153cacbaad9f61b72c4fd23
Author: Kousuke Saruta <[email protected]>
AuthorDate: Fri Aug 11 10:15:43 2023 +0900
docs: Add an example for PostgreSQL service (#2847)
* Add an example for PostgreSQL service.
* Fix doc.
* Modify style.
---
core/src/services/postgresql/docs.md | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/core/src/services/postgresql/docs.md
b/core/src/services/postgresql/docs.md
index 35ac3fff2..129e6c5e5 100644
--- a/core/src/services/postgresql/docs.md
+++ b/core/src/services/postgresql/docs.md
@@ -21,3 +21,28 @@ This service can be used to:
- `table`: Set the table of postgresql
- `key_field`: Set the key field of postgresql
- `value_field`: Set the value field of postgresql
+
+## Example
+
+### Via Builder
+
+```rust
+use anyhow::Result;
+use opendal::services::Postgresql;
+use opendal::Operator;
+
+#[tokio::main]
+async fn main() -> Result<()> {
+ let mut builder = Postgresql::default();
+ builder.root("/");
+
builder.connection_string("postgresql://you_username:[email protected]:5432/your_database");
+ builder.table("your_table");
+ // key field type in the table should be compatible with Rust's &str like
text
+ builder.key_field("key");
+ // value field type in the table should be compatible with Rust's Vec<u8>
like bytea
+ builder.value_field("value");
+
+ let op = Operator::new(builder)?.finish();
+ Ok(())
+}
+```
\ No newline at end of file