Rust 配置 diesel 库 Windows 上安装配置 (postgres、sqlite、mysql)解决diesel_cli报错或安装完后无法正常运行

Rust 配置 diesel 库 Windows 上安装配置 (postgres、sqlite、mysql)解决diesel_cli报错或安装完后无法正常运行


 

在被 rust-postgresql 折磨之后,选择了 diesel 库,这才了解到对象关系映射(Object Relational Mapping, ORM) ,
可以像使用本地变量和函数一样操作关系型数据库。这有点像非关系型数据库(如MongoDB)操作方式的意味,不过不知道孰先孰后。
diesel 提供了一个叫 diesel_cli 的工具,用来将 MySQL、PostgreSQL 或 Sqlite 上的数据表结构转换成代码
 
网上教程有点即使让你正常的安装完这个diesel_cli但依旧无法在windows上成功编译,原因是依赖另一些dll链接库,可能是最新版的缘故。
报错:
error: linking with `link.exe` failed: exit code: 1181
  |
  = note: "/* 省略一些链接参数 */"
  = note: LINK : fatal error LNK1181: cannot open input file 'libpq.lib'
error: aborting due to previous error
 
error: failed to compile `diesel_cli v1.4.0`, intermediate artifacts can be found at `C:\Users\sunnysab\AppData\Local\Temp\cargo-installhOpejX`
 
Caused by:
  could not compile `diesel_cli`.
To learn more, run the command again with --verbose.
网上不是我说解决方法治标不治本,这个解决了又来新的问题!
 
postgresql解决办法
postgresql安装包 https://www.postgresql.org/download/windows/
推荐二进制包,这样后面直接可以配置docker。
postgresql 二进制包 https://www.enterprisedb.com/download-postgresql-binaries
 
Mysql 的解决方案
这里选择对应的框架,并下载个zip包就可以。解压出来。https://downloads.mysql.com/archives/c-c/
 
SQLite 解决方案 (暂时未解决)
如果不同框架就点击此连接https://www.sqlite.org/download.html
用了汇编DOSBox编和masm编译sqlite3.lib  调用的时候还是报错未解决。
如果有能解决SQLite的请联系我
我需要将lib(libpg.lib)和pgAdmin 4/bin(.dll)的依赖给映射出来
 
 
// 如果要配置sqlite则执行下面命令
cargo install diesel_cli --no-default-features --features “sqlite-bundled”
// postgres配置 
argo install diesel_cli --no-default-features --features postgres
// mysql配置
argo install diesel_cli --no-default-features --features mysql
 
 
 

 

posted @ 2021-09-11 23:24  握着玫瑰的屠夫  阅读(1105)  评论(0编辑  收藏  举报