Reputation:
I have written a script to update my employee table in psycopg2 but the update is not happening the currr.execute is returning a None object.
my code
connm = psycopg2.connect(database="database", user = "user", password = "pass", host = "localhost", port = "5432")
connm.autocommit = True
sql = """ UPDATE employee SET name = %s WHERE phone_number = %s"""
curr = connm.cursor()
username = "Mike"
query = "+0123456789"
abc = curr.execute(sql, (username, query))
print abc
connm.commit()
curr.close()
This abc object is returning None.
Kindly help me! Thanks in advance!
Upvotes: 1
Views: 781
Reputation: 51755
Quoting "Psycopg – PostgreSQL database adapter for Python - execute command":
The method returns None. If a query was executed, the returned values can be retrieved using fetch*() methods
Then, None looks fine. Congrats :)
Edited about no effect:
Can you test your query on database?
my_raw_query=curr.mogrify(sql, (username, query))
print my_raw_query
Check if query is ok and copy paste query on database to check it again.
Upvotes: 1