Reputation: 960
I am having a problem using a relative path with SQLx and SQLite. My workspace:
workspace/
Cargo.toml
.env
base_dir/
db.sqlite
binary_crate/
src/
main.rs
The sqlx::query!
macro in main.rs is marked red in Visual Studio Code. Hovering over it shows:
error returned from database: (code: 14) unable to open database file
Which also occurs when executing cargo sqlx prepare
in the "binary_crate" directory:
error: error returned from database: (code: 14) unable to open database file
--> binary_crate\src\main.rs:21:20
|
21 | let user = sqlx::query!(
...
28 | | )
| |_________^
|
= note: this error originates in the macro `$crate::sqlx_macros::expand_query` which comes from the expansion of the macro `sqlx::query` (in Nightly builds, run with -Z macro-backtrace for more info)
I think it's due to SQLx issue #3099. Setting DATABASE_URL
in .env like this didn't change anything:
DATABASE_URL="sqlite://${CARGO_MANIFEST_DIR}/base_dir/db.sqlite"
How to workaround issue #3309 and use SQLite with a relative path on Windows 10?
Upvotes: 1
Views: 191