I am inserting into a table using the following code:
## Connection established ##
sql = """ INSERT INTO Singer ( name ) VALUES( %s ) """
params = ('Rihanna',)
cursor.execute(sql, params)
cursor.fetchall() ## Result - into no result set
cursor.description ## Result - Nonetype
I am not able to understand where am I going wrong?
Thanks
1 Answer 1
You have to commit your change.
cursor = conn.cursor()
sql = """ INSERT INTO Singer ( name ) VALUES( %s ) """
params = ('Rihanna',)
cursor.execute(sql, params)
conn.commit() # Important, apply changes to database!
cursor.fetchall() ## Result - into no result set
cursor.description ## Result - Nonetype
Sign up to request clarification or add additional context in comments.
Comments
Explore related questions
See similar questions with these tags.
default