title: Executing update query in django using JSON
body: <p>The tasks i implemented are,</p>
  
  <ol>
  <li>store  a <code>json</code> file as the string in the database.</li>
  <li>Each <code>json</code> file represents a query that can execute against a database <code>table</code> . Some examples are</li>
  </ol>
  
  <p>example 1</p>
  
  <pre><code>{ "name:"testrule1","query":"select * from students"}
  </code></pre>
  
  <p>To execute the query and get the result the user have to call the url </p>
  
  <p><a href="http://127.0.0.1/myview?testrule1" rel="nofollow">http://127.0.0.1/myview?testrule1</a></p>
  
  <p>example2</p>
  
  <pre><code>{ "name:"updaterule1","query":"UPDATE students SET name=%s, id=%s" where age=10}
  </code></pre>
  
  <p>To update the table with name = sample and id=206 user have to call the url.</p>
  
  <p><a href="http://127.0.0.1/myview?updaterule1&amp;sample&amp;206" rel="nofollow">http://127.0.0.1/myview?updaterule1&amp;sample&amp;206</a></p>
  
  <p>my objective is to store multiple json string like this in the database and
  execute the corresponding query on the url call.</p>
  
  <p>But update query is not working properly. what can i do to make it working?
  The queries and stored on database in django as json data.
  These are my files.</p>
  
  <p>views.py</p>
  
  <pre><code>def view1(request,title):
      p=query.objects.get(name=title)
      cursor=connection.cursor()
      cursor.execute(p.data["query"])
      return HttpResponse(cursor.fetchall())
  
  def view2(request,title,nam,roll):
      cursor=connection.cursor()
      q=query.objects.get(name=title)
      p=Post.objects.raw(q.data["query"],[nam],[roll])
      cursor.execute(q.data["query"]) 
      transaction.commit()
      h=Post.objects.raw('select * from posts_post')
      return HttpResponse(h)
  </code></pre>
  
  <p>urls.py</p>
  
  <pre><code>from django.conf.urls import url
  from django.contrib import admin 
  
  urlpatterns = [
      url(r'^admin/', admin.site.urls),
      url(r'^posts/$', 'posts.views.posts_home'),
      url(r'^create/$', 'posts.views.create'),   
      url(r'^results/$', 'posts.views.results'),
      url(r'^myview/(?P&lt;title&gt;[\w]+)/$', 'posts.views.view1'),
      url(r'^myview/(?P&lt;title&gt;[\w]+)&amp;(?P&lt;nam&gt;[\w]+)&amp;(?P&lt;roll&gt;      \d+)/$','posts.views.view2'),
  ]
  </code></pre>