When playing around with our demo app, the default sqlite3 is plenty. Before moving the app to production,
you'll want to use a
"real" database.
N.B. We've deprecated use of Microsoft SQL Server due to lack of support for the django database backend library.
You should use MySQL, including the AWS Aurora Serverless MySQL flavor.
ifos.environ.get('MYSQL_HOST',None):password=os.environ.get('MYSQL_PASSWORD',None)# unable to pass None/null value in environmentifpasswordandpassword.lower()=='none':password=NoneDATABASES={'default':{'ENGINE':'django.db.backends.mysql','NAME':os.environ.get('MYSQL_DB','tsc'),'USER':os.environ.get('MYSQL_USER','admin'),'PASSWORD':password,'HOST':os.environ['MYSQL_HOST'],'PORT':os.environ.get('MYSQL_PORT','3306'),'OPTIONS':{# make mysql 5.6 work sort of right'init_command':'SET default_storage_engine=INNODB,character_set_connection=utf8mb4,''collation_connection=utf8mb4_unicode_ci,''sql_mode="STRICT_TRANS_TABLES"'}}}# otherwise, using local sqlite3:else:DATABASES={'default':{'ENGINE':'django.db.backends.sqlite3','NAME':os.path.join(BASE_DIR,'db.sqlite3'),'OPTIONS':{'timeout':20,}}}
sqlite3 is by definition a local database. It's "just there" on MacOS. You may have version compatibility problems
on RHEL, but if you are to the point of running on RHEL, you should be using a MySQL database.
Because we conditionalized the database in settings.py via environment variables, don't forget to set them
in the environment. I did this with a script which I can either source or use to run one-off commands:
BEGIN;---- Create model Instructor--CREATETABLE"myapp_instructor"("id"char(32)NOTNULLPRIMARYKEY,"effective_start_date"dateNULL,"effective_end_date"dateNULL,"last_mod_user_name"varchar(80)NULL,"last_mod_date"dateNOTNULL,"instr_name"varchar(100)NOTNULLUNIQUE);CREATETABLE"myapp_instructor_course_terms"("id"integerNOTNULLPRIMARYKEYAUTOINCREMENT,"instructor_id"char(32)NOTNULLREFERENCES"myapp_instructor"("id")DEFERRABLEINITIALLYDEFERRED,"courseterm_id"char(32)NOTNULLREFERENCES"myapp_courseterm"("id")DEFERRABLEINITIALLYDEFERRED);CREATEUNIQUEINDEX"myapp_instructor_course_terms_instructor_id_courseterm_id_8f50dbb5_uniq"ON"myapp_instructor_course_terms"("instructor_id","courseterm_id");CREATEINDEX"myapp_instructor_course_terms_instructor_id_c1121f18"ON"myapp_instructor_course_terms"("instructor_id");CREATEINDEX"myapp_instructor_course_terms_courseterm_id_5af9ffbe"ON"myapp_instructor_course_terms"("courseterm_id");COMMIT;
BEGIN;---- Create model Instructor--CREATETABLE`myapp_instructor`(`id`char(32)NOTNULLPRIMARYKEY,`effective_start_date`dateNULL,`effective_end_date`dateNULL,`last_mod_user_name`varchar(80)NULL,`last_mod_date`dateNOTNULL,`instr_name`varchar(100)NOTNULLUNIQUE);CREATETABLE`myapp_instructor_course_terms`(`id`integerAUTO_INCREMENTNOTNULLPRIMARYKEY,`instructor_id`char(32)NOTNULL,`courseterm_id`char(32)NOTNULL);ALTERTABLE`myapp_instructor_course_terms`ADDCONSTRAINT`myapp_instructor_cou_instructor_id_c1121f18_fk_myapp_ins`FOREIGNKEY(`instructor_id`)REFERENCES`myapp_instructor`(`id`);ALTERTABLE`myapp_instructor_course_terms`ADDCONSTRAINT`myapp_instructor_cou_courseterm_id_5af9ffbe_fk_myapp_cou`FOREIGNKEY(`courseterm_id`)REFERENCES`myapp_courseterm`(`id`);ALTERTABLE`myapp_instructor_course_terms`ADDCONSTRAINT`myapp_instructor_course__instructor_id_courseterm_8f50dbb5_uniq`UNIQUE(`instructor_id`,`courseterm_id`);COMMIT;
As you can sess, Django's database layer hides the differences between different backend databases, so you can
focus on what's important.