You can check a good solution that I posted here. You just need a string-connection to connect to your database. For example, if you use a MySQL, the connection-string should be:
# mysqlclient
'mysql+mysqldb://username:password@host:port/database'
or
# PyMySQL
'mysql+pymysql://username:password@host:port/database')
then you can use PhpMyAdmin as a "MySQL web administration tool" to look over the database via web browsers or DataGrip (my preference) to access any database remotely.
for using the handler in Django you just need to add the handler class to the LOGGING variable of setting.py as follow:
level = 'INFO' if DEBUG else 'WARNING' # I prefer INFO in debugging mode and WARNING in production
handler = ['log_db_handler', ] # In production I rarely check the server to see console logs
if DEBUG:
handler.append('console')
LOGGING = {'version': 1,
'disable_existing_loggers': False,
'formatters': {'verbose': {'format': '{levelname} {message}', # {asctime} {module} {process:d} {thread:d}
'style': '{', }, },
'handlers': {'log_db_handler': {'level': level,
'class': 'db_logger.handlers.DBHandler',
'formatter': 'verbose', },
'console': {'class': 'logging.StreamHandler', }},
'loggers': {'db_log': {'handlers': handler,
'level': level,
'propagate': False, },
'django': {'handlers': handler,
'level': level,
'propagate': True, },
'django.request': {'handlers': handler,
'level': level,
'propagate': True, }}}
Pay attention that the 'db_logger.handlers.DBHandler' points to the handler class.