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.
Supported versions
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_URL
for MySQL and PostgreSQL add-onsMONGO_URL
for 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
DATABASE_URL
environment variable - SQLAlchemy can use the value of
DATABASE_URL
to connect to your MySQL/PostgreSQL add-on - parse-database-url configures your Node.js project's database from the
DATABASE_URL
environment variable - meteor will automatically detect the presence of
MONGO_URL
- parse-mongo-url configures your Node.js project's database from the
MONGO_URL
environment variable - pymongo can use the value of
MONGO_URL
to connect to your MongoDB add-on
Custom configuration
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 .env
file.
If you need anything else, feel free to reach us at [email protected] or read more about SourceLair add-ons here.
Wait no more, create your database add-on now and enjoy frictionless configuration of your database.