我对锈病很陌生。试图创建与柴油-rs的数据库连接。
下面是我代码的一部分:
use diesel::Connecction;
use diesel::mysql::MysqlConnection;
use diesel::sqlite::SqliteConnection;
let engine = "mysql";
let mysql_url = "mysql://username:password@localhost:3306/test";
let sqlite_url = "sqlite://sqlite.db";
let connection : Box<dyn Connection> = if engine == "mysql" {
Box::new(MysqlConnection::establish(mysql_url).unwrap())
} else {
Box::new(SqliteConnection::establish(sqlite_url).unwrap())
}下面是编译器错误:
error[E0191]: the value of the associated types `Backend` (from trait `Connection`), `TransactionManager` (from trait `Connection`) must be specified
--> src/quant/common/persistence/database.rs:11:25
|
11 | connection: Box<dyn Connection>,
| ^^^^^^^^^^ help: specify the associated types: `Connection<Backend = Type, TransactionManager = Type>`当程序以不同的参数启动时,是否有可能创建不同的连接?
发布于 2021-12-17 22:13:52
不支持此用例。见此问题。如果您能够通过连接来完成这一任务,那么您将不得不包装事务和查询,然后很可能是一些生成的table!类型,然后进入一个兔子洞。
https://stackoverflow.com/questions/70390502
复制相似问题