SQLite Connection - unable to open database file


Hello everyone, I am developing an online store in Kirby and for some processes I use a SQLite database.

To connect to the database I have defined the following function in a plugin:

function db_Connect(){    
         'database' => c::get('db.database'),
         'type'     => c::get('db.type')

And in the file config.php I define the location of the database:

c::set('db.type', 'sqlite');
c::set('db.database', 'kirby/data/db.s3db');

At first I could not connect to the database but by hosting the database in 'kirby/data/db.s3db' I solved the problem and could connect and perform queries without problem.

Now, I need to access from a widget that I created for the panel and I get the same error:
SQLSTATE [HY000] [14] unable to open database file

I guess it’s a permissions problem but I do not know where I can host the database file so I can use it from the site and from the panel at the same time.

All the queries that I make are defined in functions in my plugins so they are available everywhere.

Any ideas?

Thank you very much for the help.


Where is that kirby folder located?


Hi, thank you for responding so quickly. This is the folder structure that I use:


Ok, so you have created a new folder within the source kirby folder, I was afraid of that. Never touch the /kirby or panel folders, they will be overwritten on update and should not contain user data. Your data should sit in the root folder, above the root folder (usually not possible on shared hosting), in the assets folder, or within your content folder.


I have put the data folder in the root and changed the configuration. The site is still working but in the widget I get the same error



c::set('db.database', kirby()->roots()->index().'/data/db.s3db');


I have tried the new configuration and now the error is different:
open_basedir prohibits opening C:\WorkSpace\xampp\htdocs\mjc-web/data/db.s3db/


Sorry, I put the line wrong. I have put the following line and it seems to work correctly:

c::set('db.database', kirby()->roots()->index()."\data\db.s3db");

Thank you very much for helping me, you have been very helpful. I hope it also works for others who have this problem.

A pleasure and many thanks


Sorry, maybe the trailing slash, don’t know how that made it into it?

Edit: Ah, ok, you fixed it.