doushenmao9036 2019-01-04 10:13
浏览 203
已采纳

在Laravel中设置sqlite db的自定义路径

I want to use the sqlite db stored in "C:\Folder\my_database.sqlite" , what should i do? I want to use that sqlite db. Can anyone please suggest me a solution?

So i can give the path to sqlite in database.php below:

 'sqlite' => [
            'driver' => 'sqlite',
            'database' => "path to my sqlite db",
            'prefix' => '',
        ],

Also if that is done, then i can change my default connection to sqlite. Like:

DB::setDefaultConnection('sqlite');

Can anyone please suggest me a solution?

  • 写回答

3条回答 默认 最新

  • drdyf42880 2019-01-04 10:20
    关注

    As the Laravel Documentation states:

    After creating a new SQLite database using a command such as touch database/database.sqlite, you can easily configure your environment variables to point to this newly created database by using the database's absolute path:

     'sqlite' => [
                'driver' => 'sqlite',
                'database' => "C:\Folder\my_database.sqlite",
                'prefix' => '',
            ],
    

    To make it the default connection, just set this in your .env file:

    DB_CONNECTION=sqlite
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 HFSS设计小型化180度耦合器
  • ¥15 使用CInternetSession,CHttpFile读取网页文件时有些电脑上会卡住怎么办?
  • ¥15 水下机器人的半物理仿真研究
  • ¥15 微服务假死,一段时间后自动恢复,如何排查处理
  • ¥50 webrtc-streamer TCP rtsp
  • ¥15 cplex运行后参数报错是为什么
  • ¥15 之前不小心删了pycharm的文件,后面重新安装之后软件打不开了
  • ¥15 vue3获取动态宽度,刷新后动态宽度值为0
  • ¥15 升腾威讯云桌面V2.0.0摄像头问题
  • ¥15 关于Python的会计设计