Q. What is the purpose of writing "cursor.execute()"?
Answer :-
Once you have created a cursor, you can execute SQL query using execute() function with cursor object as per following syntax :
<cursorobject>.execute(<sql query string>)
For example, if you want to view all the records of table data which is a table in the database test to which you established connection in step 2, you can execute SQL query "select * from data" by writing :
cursor.execute("select * from data")
The above code will execute the given SQL query and store the retrieved records (i.e., the result-set) in the cursor object (namely cursor) which you can then use in your programs/scripts as required.
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )