Connect your PlanetScale databases and their branches to manage and run queries from JetBrains DataGrip in a few small steps. If you aren’t familiar with DataGrip, it is a popular, cross-platform IDE for databases that works nicely with PlanetScale databases.
Alongside DataGrip, you can manage your database changes easier with branching in PlanetScale. Database Branches® allow you to branch your database schemas like you branch your code. This enables experimenting with schemas in an isolated environment. Once you are ready to go live, non-blocking schema changes provide a schema change workflow that allows users to update database tables without locking or causing downtime for production databases.
If you have connected to a database with DataGrip as a MySQL GUI before, this experience will likely be pretty familiar to you. You will create a new Data Source in DataGrip and use the connection information provided by PlanetScale to have a secure connection. Here’s how to do it:
In DataGrip, go to File > New… > Data Source… > MySQL
In PlanetScale, you can either create a new PlanetScale database or use an existing database. Navigate to the database and branch of your choice, select the Connect dropdown and Generate a new password. Back in DataGrip, you will copy over the following information from your new password in the General tab:
username(user in DataGrip)
You will also need to give your database a Name in DataGrip. We recommend a name that includes what branch you are connecting to in PlanetScale. This makes it easier to identify the different branches you are working with in DataGrip. I like to use the following format:
<database-name> (<branch-name>), which would look like
In the SSH/SSL tab, make sure to check the Use SSL box and set the Mode to Full Verification. Since DataGrip is JDBC-based, it uses your system’s root CA certificate, so you do not need to fill in the CA file or any other file locations. PlanetScale will only connect to a database over SSL.
- You can Test Connection in the DataGrip module. You should see a success message. If you don’t, please feel free to reach out to us here!
And you are ready to start using your PlanetScale database in DataGrip!
Important: PlanetScale does not allow create, drop and alter statements on production branches with safe migrations enabled. This enables developers to make schema changes without the fear of dropping columns, locking tables, or causing downtime in your app. So if you want to create a table, make sure you are doing it in a development branch, not a production branch.
First, create a table in DataGrip. As a reminder:
- In DataGrip, right-click on your database name and select New... > Table.
- Add your columns, keys, etc. (Reminder: PlanetScale does not support foreign key constraints, learn how to operate without them here.)
- Select Execute, which will create the table in your PlanetScale database branch.
Next, after creating a table in DataGrip, you can see your new table in the PlanetScale Console. I created a users table in DataGrip, which I can see in the Console (located in PlanetScale as a tab within your database branch) when I run the query:
Lastly, when you are ready to use the table in your production database, learn how to make a deploy request to merge your latest changes to your database. Once you merge your changes in PlanetScale, your production database in DataGrip will automatically update with the changes.