Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to connect an existing database with Strapi CMS?

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?

like image 405
Elena Valari Avatar asked Jun 30 '20 11:06

Elena Valari


People also ask

Does Strapi use a database?

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.

What databases does Strapi support?

# 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.

Can I use MySQL on Strapi?

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.

How do you make a Strapi table?

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.


3 Answers

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 ...

like image 112
machineghost Avatar answered Nov 15 '22 09:11

machineghost


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

like image 20
ovyas24 Avatar answered Nov 15 '22 08:11

ovyas24


The best way is to create a new database with the same structure but created with strapi and after migrate the data.

like image 27
cristian camilo cedeño gallego Avatar answered Nov 15 '22 10:11

cristian camilo cedeño gallego