You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@opendal.apache.org by "Iam-WenYi (via GitHub)" <gi...@apache.org> on 2025/04/05 12:54:55 UTC
bug: Can't use postgresql-service
GitHub user Iam-WenYi created a discussion: bug: Can't use postgresql-service
### Describe the bug
The example code gived in postgresql's service markfodown document can't run.
<!-- Uploading "微信图片_2025-04-05_190044_247.png"... -->
<!-- Uploading "微信图片_2025-04-05_190040_526.png"... -->
<!-- Uploading "微信图片_2025-04-05_190036_206.png"... -->
<!-- Uploading "微信图片_2025-04-05_190031_271.png"... -->
<!-- Uploading "微信图片_2025-04-05_190025_294.png"... -->
<!-- Uploading "微信图片_2025-04-05_190016_094.png"... -->
### Steps to Reproduce
1. Make a copy of `ofs` directory, rename to `postgresql-opendal-try/`
2. Chanage Cargo.toml to this:
```toml
# 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 <we...@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"
```
3. Change main.rs to this:
```rust
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(())
}
```
4. Cargo build

### Expected Behavior
I want to use the OpenDAL to connect to the postgresql, but I can't
### Additional Context
_No response_
### Are you willing to submit a PR to fix this bug?
- [ ] Yes, I would like to submit a PR.
GitHub link: https://github.com/apache/opendal/discussions/5961
----
This is an automatically sent email for dev@opendal.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@opendal.apache.org
Re: bug: Can't use postgresql-service
Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
GitHub user Xuanwo added a comment to the discussion: bug: Can't use postgresql-service
Hi, @Iam-WenYi, as suggested in the error message: `opendal::services::Postgresql` is a different thing from `opendal::Scheme::Postgersql`. Please don't mix use them.
GitHub link: https://github.com/apache/opendal/discussions/5961#discussioncomment-12734332
----
This is an automatically sent email for dev@opendal.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@opendal.apache.org
Re: Can't use postgresql-service
Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
GitHub user Xuanwo added a comment to the discussion: Can't use postgresql-service
Also, OpenDAL doesn't enable all services by default. Instead, it uses `features` to select which services to use. So, you'll also need to make sure that `pg` has been enabled, like this:
```rust
opendal = { version = "0.53.0", path = "../../core", features = ["services-postgresql"] }
```
And the last thing, opendal rust core (`core`) and `oli` are differnt projects.
> Make a copy of `ofs` directory, rename to `postgresql-opendal-try/`
Doesn't make sense to me.
GitHub link: https://github.com/apache/opendal/discussions/5961#discussioncomment-12734365
----
This is an automatically sent email for dev@opendal.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@opendal.apache.org
Re: Can't use postgresql-service
Posted by "Iam-WenYi (via GitHub)" <gi...@apache.org>.
GitHub user Iam-WenYi edited a discussion: Can't use postgresql-service
### Describe the bug
The example code gived in postgresql's service markfodown document can't run.
<!-- Uploading "微信图片_2025-04-05_190044_247.png"... -->
<!-- Uploading "微信图片_2025-04-05_190040_526.png"... -->
<!-- Uploading "微信图片_2025-04-05_190036_206.png"... -->
<!-- Uploading "微信图片_2025-04-05_190031_271.png"... -->
<!-- Uploading "微信图片_2025-04-05_190025_294.png"... -->
<!-- Uploading "微信图片_2025-04-05_190016_094.png"... -->
### Steps to Reproduce
1. Make a copy of `ofs` directory, rename to `postgresql-opendal-try/`
2. Chanage Cargo.toml to this:
```toml
# 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 <we...@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"
```
3. Change main.rs to this:
```rust
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(())
}
```
4. Cargo build

### Expected Behavior
I want to use the OpenDAL to connect to the postgresql, but I can't
### Additional Context
_No response_
### Are you willing to submit a PR to fix this bug?
- [ ] Yes, I would like to submit a PR.
GitHub link: https://github.com/apache/opendal/discussions/5961
----
This is an automatically sent email for dev@opendal.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@opendal.apache.org