Set the DB_DATABASE environment variable
abubaker417 opened this issue · comments
AbuBaker commented
I have installed orator
in django
Python 3.9.7
django 4.0.5
I create a migration and model in the root that you can see my code and set connection but when i'm running migrate command orator migrate
then coming these issues
[ImproperlyConfigured]
Set the DB_DATABASE environment variable
migrate [-c|--config CONFIG] [-d|--database DATABASE] [-p|--path PATH] [-s|--seed] [--seed-path SEED-PATH] [-P|--pretend] [-f|--force]
db connection in the root
from orator import DatabaseManager, Schema
import environ
env = environ.Env()
environ.Env.read_env()
databases = {
'mysql': {
'driver': 'mysql',
'host': 'localhost',
'database': env('DB_DATABASE'),
'user': env('DB_USERNAME'),
'password': env('DB_PASSWORD'),
'prefix': ''
}
}
db = DatabaseManager(databases)
schema = Schema(db)
migration file
from orator.migrations import Migration
class CreateProductsable(Migration):
def up(self):
"""
Run the migrations.
"""
with self.schema.create('products') as table:
table.increments('id')
table.integer('category_id').unsigned()
table.timestamps()
table.foreign('category_id').references('id').on('jobs').on_delete('cascade')
def down(self):
"""
Revert the migrations.
"""
self.schema.drop('products')
model file
from orator import Model
class Product(Model):
__table__ = 'products'
Please can you help me about this issue where i'm doing mistake . Thanks in advance
Marco Occhialini commented
are you sure that the env('DB_DATABASE´)
is returning a non-empty string?