SQL
SQL
Now we will access and manipulate our database using a python program.
To connect our python script to a MySQL database, we need some special functions,
for which we have a library mysql connector.
if mycon.is_connected( ):
print('Successfully Connected to MySQL database')
Creating cursor instance
Step 3 :
When we send our query to the server where it gets executed, the result(what we
asked in query) is sent back to us in one go. But if we want to access the retrieved
data one row at a time, we can’t do it directly. A control structure called database
cursor can be created that gets access of all the records retrieved as per query and
allows us to traverse the result row by row.
cur = mycon.cursor( )
<connector object>.close( )
e.g. mycon.close( )
Parameterized Queries
n=33