Empty Database after config


I made a website with Kirby (online soon), and now I am testing the database feature.
I create a mysql db and my config.php is ok.
But this

$users = Db::select('users');

Return :frowning:
Invalid table: users

It’s true, no table in my database.
Is it automatic or I have to put manually from txt to my db ?

Kirby just makes it easy to connect to a database. It is up to you to set out the tables etc for how you want to store things, and then write code to work with that structure.

For instance, if you have database full of data from another system, you can turn that data into virtual pages. there is a guide here…

It’s not meant to replace the flat file structure (but you could do that if you really wanted to.). It’s more for giving extra flexibility. There are certain kinds of data that are better suited to a database, so Kirby allows for that with the database connectors.

You can either create your tables directly in your database, using tools like PHPMyAdmin, Azure Data Studio or whatever, or create your tables etc. with PHP/Kirby’s API.

Maybe if you provide some more info what you are trying to achieve, we can help you better.

OK :slight_smile:
I would like to use the kirby panel for my next project.
I need to work with around 9999 items (from a csv and manualy), view, modify, add, remove, sort, find, join images…
Did you know if database is mandatory ?
May be I can fill or update the database with this hook

You can actually do it from the spreadsheet itself, and merge it with other data…

If you import your csv stuff into a database (this can be done programmatically or you can import the file into your database using one of the tools already mentioned above or similar), you can then manage that content from the Kirby Panel, by following the Virtual Pages guide.

Theoretically, writing to a csv file should be possible as well, but I’m not so sure this is such a good idea and would require additional plugins.

Depending on the structure of your site, a database might not even be necessary, you could also import your csv file as real Kirby pages.