开发者

Python/MySQL: Query executes but nothing happens?

开发者 https://www.devze.com 2023-03-12 01:04 出处:网络
I\'m executing a simple query with Python but nothing seems to happen when it executes, just as if it sk开发者_如何学Pythonipped the execution.

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')
0

精彩评论

暂无评论...
验证码 换一张
取 消