Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add metadata about internal db connection in common_data #3299

Merged
merged 3 commits into from
Nov 8, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions mathesar/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from config.settings.common_settings import DATABASES
from django.conf import settings
from django.contrib.auth.decorators import login_required
from django.shortcuts import render, redirect, get_object_or_404
Expand Down Expand Up @@ -153,9 +154,23 @@ def get_base_data_all_routes(request, database=None, schema=None):
'is_authenticated': not request.user.is_anonymous,
'live_demo_mode': get_is_live_demo_mode(),
'current_release_tag_name': __version__,
'internal_database': get_internal_db_meta(),
}


def get_internal_db_meta():
internal_db = DATABASES['default']
if internal_db['ENGINE'].startswith('django.db.backends.postgresql'):
return {
'type': 'postgres',
'user': internal_db['USER'],
'host': internal_db['HOST'],
'port': internal_db['PORT'],
'database': internal_db['NAME']
}
return {'type': 'sqlite'}


def get_common_data(request, database=None, schema=None):
return {
**get_base_data_all_routes(request, database, schema),
Expand Down