我正在尝试从rusqlite => sqlx进行转换。
从rusqlite中打开一个连接,调用SQLite::open,并创建db文件。以下工作:
use rusqlite::Connection;
Connection::open(db_filename)但是,我正在关注sqlx端(https://github.com/launchbadge/sqlx#connecting)上的文档,它们会立即启动我来创建一个池:
use sqlx::sqlite::{SqlitePoolOptions};
SqlitePoolOptions::new()
.max_connections(1)
.connect(&format!("sqlite://{}", db_filename))
.await
.map_err(|err| format!("{}\nfile: {}", err.to_string(), db_filename))?;它实际上产生了以下的Result<_, String>消息:
Error: "error returned from database: unable to open database file\nfile: /path/to/my.db"我不清楚在sqlx世界中如何在第一次引导时实际编写那些db文件。
小费?
发布于 2022-06-26 17:17:22
我在他们的问题跟踪器中发现了一个问题,您可以在文件名上使用?mode=rwc查询样式param。
https://github.com/launchbadge/sqlx/issues/1114#issuecomment-827815038
添加查询解决了问题。
https://stackoverflow.com/questions/72763578
复制相似问题