MindsDB enables you to group all objects within projects.

Projects store all MindsDB schema objects except for handlers, connected data sources, and configured AI/ML engines. That is, projects can store models, views, jobs, triggers, agents, skills, knowledge bases, and chatbots.

MindsDB provides the default mindsdb project where all objects created without defining a project are stored.

Working with MindsDB Projects

Create a Project

Use the below command to create a project.

CREATE PROJECT project_name;

Use lower-case letters for a project name.

List All Projects

Use the below command to list all projects.

SHOW [FULL] DATABASES
WHERE type = 'project';

Create an Object within a Project

Use the below command template to create an object within a project.

CREATE <OBJECT> project_name.object_name
...;

Drop a Project

Use the below command to remove a project.

DROP PROJECT project_name;

Please note that if your project stores at least one object, it cannot be removed. In this case, you should first drop all the objects belonging to this project, and then, you can remove the project. Please see the Example section for details.

Example

Let’s create a project.

CREATE PROJECT my_project;

To verify that the project was created successfully, let’s run the command below to select all databases, including connected data sources and projects.

SHOW FULL DATABASES;

On execution, we get:

+------------------+-------+------+
|Database          |TYPE   |ENGINE|
+------------------+-------+------+
|information_schema|system |[NULL]|
|mindsdb           |project|[NULL]|
|my_project        |project|[NULL]|
|files             |data   |files |
+------------------+-------+------+

Please note that information_schema is the system database, mindsdb is the default project, and files is the database to store all uploaded files. For more information, please visit our docs on MindsDB default structure.

Now we create a model within the project.

CREATE MODEL my_project.my_model
FROM example_db
    (SELECT * FROM demo_data.home_rentals)
PREDICT rental_price;

Also, let’s create a view.

CREATE VIEW my_project.my_view (
    SELECT * 
    FROM example_db.demo_data.home_rentals
);

Here is what we have in the my_project project.

SHOW TABLES FROM my_project;

On execution, we get:

+--------------------+
|Tables_in_my_project|
+--------------------+
|my_model            |
|my_view             |
+--------------------+

Let’s try to delete our project.

DROP PROJECT my_project;

On execution, we get:

Project 'my_project' can not be deleted, because it contains tables: my_model, my_view

Users should remove all project content before dropping a project.

DROP MODEL my_project.my_model;
DROP VIEW my_project.my_view;

Now we can proceed to drop a project.

DROP PROJECT my_project;

Next Steps

Below are the links to help you explore further.