kay899's avatar

SQLite Database Config not working for Artisan

I try to use Lumen with SQLite.

If I have this setup in my .env

DB_CONNECTION=sqlite DB_DATABASE='../storage/database.sqlite'

then, this is working: $results = User::all();

but, when I try to migrate via Artisan, I'll get:

"Database (../storage/database.sqlite) does not exists.

When I change my .env to:

DB_CONNECTION=sqlite DB_DATABASE='storage/database.sqlite'

then Artisan is working, but $results = User::all() give this error: Database (storage/database.sqlite) does not exist.

It seems that Artisan is looking for that SQLite Database from another folder?

0 likes
8 replies
bobbybouwmann's avatar

You only need to change the DB_CONNECTION variables to sqlite. Also don't forget to create the database.sqlite file in the storage directory!

kay899's avatar

@bobbybouwmann if I do only that, I'll get this error in Artisan AND when I try to use Eloquent also:

Database (C:\xampp\htdocs\cvstefan/database/database.sqlite) does not exist.

My database is in storage folder and named database.sqlite

banago's avatar

Had the same issue. This is how you sove it:

DB_DATABASE=../database/database.sqlite

You need the ../ because laravel loads from public/index.php. I hope it helps.

1 like
Juukie's avatar

@banago that works indeed but it fails when using the artisan CLI :(. I had to change it to #DB_DATABASE= so it works both in browser and the commandline.

I've raised an issue on Github for this problem.

Please or to participate in this conversation.