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条)

报告相同问题?