I am trying to create an API using Strapi CMS. I have an existing PostgreSQL + postgis database and I would like to connect-use this database in a Strapi project.
Do you know if it is possible to do something like this?
Strapi contains both a server and a database. The server hosts the APIs, and the database is used to store the application's content. Strapi uses the Koajs framework for its server.
# Databases installation guides Strapi gives you the option to choose the most appropriate database for your project. It currently supports PostgreSQL, SQLite, MySQL and MariaDB.
To connect Strapi with MySQL, you have to make sure that the authentication plugin for our root user is mysql_native_password . Currently, Strapi doesn't support the auth plugin that comes with MySQL 8.0.
In Strapi, we can create tables by adding a Content Type. So let's dive in and create one for our Painter table. Click on Content Type Builder in the left-side menu and under Content Types click on Create new content type. Enter Painter under Display name and click Continue.
I was looking for an answer for this also, but it seems the only answer is no, because Strapi is not schema-agnostic: you must adopt their database structure to use Strapi.
Now if I could only figure out a way to ask Stack Overflow for a schema-agnostic headless CMS ... without getting it flagged as an invalid/subjective question ...
You can do it while you create a strapi app just choose custom and setup the database there. and to import existing tables from that db just create a mock table using strapi admin panel and in /api folder in your project root folder and copy paste the table data you just created in api folder and chage the name of that folder to the table name and do same for the files in side that folder and,
in the api>(your table folder)>config>routes.json file change the name of table inside I will add a link to help you better understand.
for setup in strapi with existing database> configure-strapi-postgresql
I couldn't find the tut for setting up exist but this is for mysql setps are smilers.
strapi with sql
The best way is to create a new database with the same structure but created with strapi and after migrate the data.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With