1

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?

2
  • Not exactly sure what the problem is, but have you tried replacing "path to my sqlite db" with "C:\Folder\my_database.sqlite" in that code? Commented Jan 4, 2019 at 10:17
  • 'database' => env('DB_DATABASE_LITE', "C:\Folder\my_database.sqlite"), Will this work? Commented Jan 4, 2019 at 10:20

3 Answers 3

4

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
Sign up to request clarification or add additional context in comments.

Comments

2

Open your .env file and set,

DB_CONNECTION=sqlite
DB_DATABASE=C:\Folder\my_database.sqlite

further more information you can see: https://laravel.com/docs/5.7/database

Comments

1

for set sqlite database you can add absoulate path like this in database.php file..

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

for set a default sqlite connection update this in your .env file:

DB_CONNECTION=sqlite

for production update line(number 16) in database.php

'default' => env('DB_CONNECTION', 'sqlite'),

and then run this command in terminal for remove old configration and create new configration file.

php artisan config:cache

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.