Back to Mindsdb

Connect a Data Source

docs/sdks/python/create_database.mdx

26.1.0643 B
Original Source

Description

The get_database() and create_database() functions enable you to use the existing data source or connect a new one.

Syntax

You can use the get_database() method to get an existing database:

python
mysql_demo_db = server.get_database('mysql_demo_db')

Or, the create_database() method to connect a new data source to MindsDB:

python
mysql_demo_db = server.create_database(
    engine = "mysql",
    name = "mysql_demo_db",
    connection_args = {
      "user": "user",
      "password": "MindsDBUser123!",
      "host": "samples.mindsdb.com",
      "port": "3306",
      "database": "public"
    }
)