我在粗粒岩文档中阅读了以下内容:
Connection::open(path)等同于Connection::open_with_flags(path, SQLITE_OPEN_READ_WRITE | SQLITE_OPEN_CREATE)。
我将其复制到以下简单代码中:
extern crate rusqlite;
use rusqlite::Connection;
fn main() {
let path = "/usr/local/data/mydb.sqlite";
let conn = Connection::open_with_flags(path, SQLITE_OPEN_READ_WRITE | SQLITE_OPEN_CREATE);
}我实际上想用SQLITE_OPEN_READ_ONLY替换这些标志,但我认为这是一个很好的起点。
我得到以下错误:
error[E0425]: cannot find value `SQLITE_OPEN_READ_WRITE` in this scope
--> src/main.rs:6:50
|
6 | let conn = Connection::open_with_flags(path, SQLITE_OPEN_READ_WRITE | SQLITE_OPEN_CREATE);
| ^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
error[E0425]: cannot find value `SQLITE_OPEN_CREATE` in this scope
--> src/main.rs:6:75
|
6 | let conn = Connection::open_with_flags(path, SQLITE_OPEN_READ_WRITE | SQLITE_OPEN_CREATE);
| ^^^^^^^^^^^^^^^^^^ not found in this scope我好像错过了像use rusqlite::Something;这样的东西,但那是什么呢?我想不出。
我的Cargo.toml中有以下内容
[dependencies.rusqlite]
version = "0.13.0"
features = ["bundled"]发布于 2018-02-16 15:07:29
等于
Connection::open_with_flags。
你应该看看文档
fn open_with_flags<P: AsRef<Path>>(
path: P,
flags: OpenFlags
) -> Result<Connection>const SQLITE_OPEN_READ_ONLY: OpenFlags合在一起:
extern crate rusqlite;
use rusqlite::{Connection, OpenFlags};
fn main() {
let path = "/usr/local/data/mydb.sqlite";
let conn = Connection::open_with_flags(path, OpenFlags::SQLITE_OPEN_READ_ONLY);
}https://stackoverflow.com/questions/48829416
复制相似问题