Today, we're excited to introduce multiple versions for our MySQL, PostgreSQL and MongoDB add-on offerings.
Add-ons in SourceLair help you develop your applications better, by ensuring development and production environment parity - since, like in your production deployment, databases in SourceLair are separate components and not another process in your development VM.
Starting today, our supported databases and versions have been extended to the ones below, available for all projects - both old and new ones:
- MySQL - 5.6, 5.7
- PostgreSQL - 9.4, 9.5
- MongoDB - 2.6, 3.0, 3.2
Patches (minor version numbers) are automatically updated as released.
Connecting to your database
Previously, connecting to your database would require creating a database in your database server using the CLI, configuring your project and keeping different configuration files for different environments (ie SourceLair and production).
Now, when you create a new database add-on, the following will be done automatically by SourceLair:
- A new database named "sourcelair" will be created
- The following environment variables will be automatically injected in your project
DATABASE_URLfor MySQL and PostgreSQL add-ons
MONGO_URLfor MongoDB add-ons
This means that as soon as you create your SourceLair project, it will automatically find and connect to your database, given that you follow the "Store config in the environment" 12-factor principle.
Configuring your project using the environment
There are libraries in place, which you can use to connect to your Database using environment variables. Some examples of such libraries are below:
- dj-database-url configures your Django project's database from the
- SQLAlchemy can use the value of
DATABASE_URLto connect to your MySQL/PostgreSQL add-on
- parse-database-url configures your Node.js project's database from the
- meteor will automatically detect the presence of
- parse-mongo-url configures your Node.js project's database from the
- pymongo can use the value of
MONGO_URLto connect to your MongoDB add-on
If you still want a custom configuration though, you can use your database's CLI from your SourceLair terminal to access your database server and then configure your project's environment variables using a
Wait no more, create your database add-on now and enjoy frictionless configuration of your database.