php - Laravel Sqlite 数据库无法连接
问题描述
当我导航到我的服务器(Ubuntu)上的应用程序时,我得到以下信息:
Data: { message: 'could not find driver (SQL: select * from "projects" order by "created_at" desc)',
exception: 'Illuminate\\Database\\QueryException',
file: '/root/project/api/vendor/laravel/framework/src/Illuminate/Database/Connection.php',
line: 664,
trace:
[ { file: '/root/project/api/vendor/laravel/framework/src/Illuminate/Database/Connection.php',
line: 624,
function: 'runQueryCallback',
class: 'Illuminate\\Database\\Connection',
type: '->' },
但是在本地它可以工作。所以我想也许驱动程序没有安装,但是当我运行以下命令时,它显示我已经安装了 sqlite:
sqlite3 -version
3.19.3 2017-06-08 14:26:16 0ee482a1e0eae22e08edc8978c9733a96603d4509645f348ebf55b579e89636b
我的数据库配置如下所示,默认为 sqlite:
'sqlite' => [
'driver' => 'sqlite',
'database' => env('DB_DATABASE', database_path('database.db')),
'prefix' => '',
],
我下一步要弄清楚为什么这不起作用?
解决方案
您已经安装了 sqlite3,但没有安装 php 的驱动程序。该驱动程序也称为 sqlite3,因此对于例如 Ubuntu/Debian,它将是sudo apt-get install php7.2-sqlite3
.
推荐阅读
- powershell - 解析日志文件,匹配字符串数组
- snowflake-cloud-data-platform - 仅使用 REST 和 SQL 命令批量插入到 Snowflake
- c-preprocessor - 如何在 Eclipse CDT 中包含用户预处理器?
- java - 同一页面中的多个 AjaxLazyLoadPanel Wicket 8
- python - IndexError 超出范围,但列表元素仍然打印
- javascript - 如何防止在 WIFI 之外访问我的网页?
- javascript - 当我们使用模板文字时,`use strict` 不起作用
- ruby-on-rails - 接受一个记录和多个关联记录的表格?
- python - 如何将列表索引验证为整数?
- python - 我如何解决这个 python 硒问题?