예제 #1
0
def create_database(request):

  if request.method == "POST":
    data = request.POST.copy()
    data.setdefault("use_default_location", False)
    form = CreateDatabaseForm(data)

    if form.is_valid():
      proposed_query = django_mako.render_to_string("create_database_statement.mako", {
        'database': form.cleaned_data,
      })
      query = hql_query(proposed_query)
      return execute_directly(request, query, on_success_url=reverse('metastore:databases'))
  else:
    form = CreateDatabaseForm()

  return render("create_database.mako", request, {
    'database_form': form,
  })
예제 #2
0
def create_database(request):

  if request.method == "POST":
    data = request.POST.copy()
    data.setdefault("use_default_location", False)
    form = CreateDatabaseForm(data)

    if form.is_valid():
      proposed_query = django_mako.render_to_string("create_database_statement.mako", {
        'database': form.cleaned_data,
      })
      # Mako outputs bytestring in utf8
      proposed_query = proposed_query.decode('utf-8')
      query = hql_query(proposed_query)
      return execute_directly(request, query, on_success_url=reverse('metastore:databases'))
  else:
    form = CreateDatabaseForm()

  return render("create_database.mako", request, {
    'database_form': form,
  })
예제 #3
0
def create_database(request):
  db = dbms.get(request.user)

  if request.method == "POST":
    data = request.POST.copy()
    data.setdefault("use_default_location", False)
    form = CreateDatabaseForm(data)

    if form.is_valid():
      proposed_query = django_mako.render_to_string("create_database_statement.mako", {
        'database': form.cleaned_data,
      })
      # Mako outputs bytestring in utf8
      proposed_query = proposed_query.decode('utf-8')
      query = hql_query(proposed_query)
      return execute_directly(request, query, on_success_url=reverse('catalog:show_databases'))
  else:
    form = CreateDatabaseForm()

  return render("create_database.mako", request, {
    'database_form': form,
  })