I'm executing a simple query with Python but nothing seems to happen when it executes, just as if it sk开发者_如何学Pythonipped the execution.
Here's the code:
def somefunction(search_query):
from django.db import connection, transaction
search_query = search_query.strip()
cursor = connection.cursor()
rows = cursor.execute("INSERT INTO searches (query) VALUES ('"+ search_query +"')")
There's nothing wrong with the query, i get no error message or nothing, it's just not working!
Any ideas?
Perhaps you have to commit your changes:
cursor.execute('COMMIT')
精彩评论