PostgreSQL
Guide to using PostgreSQL with BlazingAPI
When deploying a BlazingAPI project, you can choose to use PostgreSQL as your database. This guide will show you how to set up PostgreSQL with BlazingAPI.
The connection is defined by the property DB_CONNECTION
in the settings.py
file.
To use PostgreSQL, you need to specify the following attributes in the DB_CONNECTION
dictionary:
driver
: The database driver to use. For PostgreSQL, usepostgres
.host
: The hostname of the database server.port
: The port number of the database server.database
: The name of the database to connect to.user
: The username to use when connecting to the database.password
: The password to use when connecting to the database.
Here is an example of how to configure PostgreSQL in the settings.py
file:
import os
...
DB_CONNECTION = {
'driver': 'postgres',
'host': os.environ['POSTGRES_HOST'],
'port': '5432',
'database': os.environ['DATABASE_NAME']
'user': os.environ['USERNAME'],
'password': os.environ['PASSWORD']
}
...
Now BlazingAPI will use PostgreSQL as the database for your project.
Good to know
BlazingAPI uses the psycopg2
library to connect to PostgreSQL databases.