-
Describe the bugThe example code gived in postgresql's service markfodown document can't run. Steps to Reproduce
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
[package]
categories = ["postgresql-service-example"]
description = "OpenDAL PostgreSQL Service Example"
keywords = ["storage", "data", "postgresql"]
name = "postgresql-service-example"
version = "0.0.1"
authors = ["Wen Yi <wen-yi@qq.com>"]
edition = "2021"
homepage = "https://opendal.apache.org/"
license = "Apache-2.0"
repository = "https://github.com/apache/opendal"
rust-version = "1.80"
[dependencies]
anyhow = { version = "1" }
clap = { version = "4.5.21", features = ["derive", "env"] }
log = { version = "0.4.22" }
logforth = { version = "0.23.1", default-features = false }
opendal = { version = "0.53.0", path = "../../core" }
tokio = { version = "1.37.0", features = [
"fs",
"macros",
"rt-multi-thread",
"io-std",
"signal",
] }
url = { version = "2.5.4" }
[target.'cfg(any(target_os = "linux", target_os = "freebsd", target_os = "macos"))'.dependencies]
fuse3 = { version = "0.8.1", "features" = ["tokio-runtime", "unprivileged"] }
fuse3_opendal = { version = "0.0.14", path = "../../integrations/fuse3" }
libc = "0.2.154"
nix = { version = "0.29.0", features = ["user"] }
[target.'cfg(target_os = "windows")'.dependencies]
cloud-filter = { version = "0.0.5" }
cloud_filter_opendal = { version = "0.0.7", path = "../../integrations/cloud_filter" }
[features]
default = ["services-fs", "services-s3"]
services-fs = ["opendal/services-fs"]
services-s3 = ["opendal/services-s3"]
[dev-dependencies]
opendal = { version = "0.53.0", path = "../../core", features = ["tests"] }
tempfile = "3.16.0"
test-context = "0.4.1"
walkdir = "2.5.0"
use anyhow::Result;
use opendal::services::Postgresql;
use opendal::Operator;
#[tokio::main]
async fn main() -> Result<()> {
let mut builder = Postgresql::default()
.root("/")
.connection_string("postgresql://you_username:your_password@127.0.0.1:5432/your_database")
.table("your_table")
// key field type in the table should be compatible with Rust's &str like text
.key_field("key")
// value field type in the table should be compatible with Rust's Vec<u8> like bytea
.value_field("value");
let op = Operator::new(builder)?.finish();
Ok(())
}
Expected BehaviorI want to use the OpenDAL to connect to the postgresql, but I can't Additional ContextNo response Are you willing to submit a PR to fix this bug?
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
Hi, @Iam-WenYi, as suggested in the error message: |
Beta Was this translation helpful? Give feedback.
-
|
Also, OpenDAL doesn't enable all services by default. Instead, it uses opendal = { version = "0.53.0", path = "../../core", features = ["services-postgresql"] }And the last thing, opendal rust core (
Doesn't make sense to me. |
Beta Was this translation helpful? Give feedback.

Also, OpenDAL doesn't enable all services by default. Instead, it uses
featuresto select which services to use. So, you'll also need to make sure thatpghas been enabled, like this:And the last thing, opendal rust core (
core) andoliare differnt projects.Doesn't make sense to me.