docs: def mode_database_functions():
      "Select a function to perform from chill.database"
  
      print globals()['mode_database_functions'].__doc__
      selection = True
      database_functions = [
              'init_db',
              'insert_node',
              'insert_node_node',
              'delete_node',
              'select_node',
              'insert_route',
              'insert_query',
              'add_template_for_node',
              'fetch_query_string',
              ]
      while selection:
          choices = database_functions + [
              'help',
              ]
          selection = select(choices)
  
          if selection:
              print globals().get(selection).__doc__
          if selection == 'init_db':
              confirm = raw_input("Initialize new database y/n? [n] ")
              if confirm == 'y':
                  init_db()
          elif selection == 'insert_node':
              name = raw_input("Node name: ")
              value = raw_input("Node value: ")
              node = insert_node(name=name, value=value or None)
              print "name: %s \nid: %s" % (name, node)
  
          elif selection == 'insert_query':
              sqlfile = choose_query_file()
              if sqlfile:
                  node = existing_node_input()
                  if node >= 0:
                      insert_query(name=sqlfile, node_id=node)
                      print "adding %s to node id: %s" % (sqlfile, node)
  
          elif selection == 'insert_node_node':
              print "Add parent node id"
              node = existing_node_input()
              print "Add target node id"
              target_node = existing_node_input()
              if node >= 0 and target_node >= 0:
                  insert_node_node(node_id=node, target_node_id=target_node)
  
          elif selection == 'delete_node':
              node = existing_node_input()
              if node >= 0:
                  delete_node(node_id=node)
  
          elif selection == 'select_node':
              node = existing_node_input()
              if node >= 0:
                  result = select_node(node_id=node)
                  print safe_dump(dict(zip(result[0].keys(), result[0].values())), default_flow_style=False)
  
          elif selection == 'insert_route':
              path = raw_input('path: ')
              weight = raw_input('weight: ') or None
              method = raw_input('method: ') or 'GET'
              node = existing_node_input()
              if node >= 0:
                  insert_route(path=path, node_id=node, weight=weight, method=method)
          elif selection == 'add_template_for_node':
              folder = current_app.config.get('THEME_TEMPLATE_FOLDER')
              choices = map(os.path.basename,
                          glob(os.path.join(folder, '*'))
                          )
              choices.sort()
              templatefile = select(choices)
              if templatefile:
                  node = existing_node_input()
                  if node >= 0:
                      add_template_for_node(name=templatefile, node_id=node)
                      print "adding %s to node id: %s" % (templatefile, node)
  
          elif selection == 'fetch_query_string':
              sqlfile = choose_query_file()
              if sqlfile:
                  sql = fetch_query_string(sqlfile)
                  print sql
  
          elif selection == 'help':
              print "------"
              for f in database_functions:
                  print "\n** %s **" % f
                  print globals().get(f).__doc__
              print "------"
          else:
              pass