How can I query the database from the backend code?

System Information
  • 3.6.8:
  • Win x64:
  • SQLite:
  • 14.17.6:
  • 7.18.0:
  • 1.22.5:

I want to put my stripe API_KEY inside the SQLite db, for my client to be able to set his API from the strapi admin panel.

Is there a way to call the database to get this API_KEY, and set it to an environment variable in the backend code?


Thank you very much in advance!

Welcome @salo08
So I would if you are trying to do do, why not just make a text field, and put the key in there.
You can always make sure the person is authenticated when accessing your api.

I’m not really sure why you want to sure tour api keys though, as you might want to keep them private?

Use environment variables - This exactly what they are for. You could do something like this by looking into an ORM which you could use to put this api key on the database and then retrieving it before the database uses that service.

Look into custom queries but I dont think you want to go this route…