Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- from django.template import RequestContext
- from django.shortcuts import render_to_response
- from django.http import HttpResponse
- import MySQLdb
- DB_USER = 'root'
- DB_PASS = '14121988'
- DB_BASE = 'Decanat'
- def index(request):
- cont = {}
- self={}
- if request.method == "POST":
- if 'sqlcode' in request.POST:
- t=request.POST['sqlcode']
- self.db_conn = MySQLdb.connect(user=DB_USER, passwd=DB_PASS, db=DB_BASE)
- self.cursor = self.db_conn.cursor(cursorclass=MySQLdb.cursors.DictCursor)
- self.cursor.execute(t)
- res = self.cursor.fetchall()
- self.send_response(200)
- elf.send_header('Content-type','text/html; charset=utf-8')
- self.end_headers()
- cont['result'] = res
- return render_to_response("index.html",cont, context_instance=RequestContext(request))
Add Comment
Please, Sign In to add comment