0% found this document useful (0 votes)
2 views13 pages

Python Database Connectivity Steps

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views13 pages

Python Database Connectivity Steps

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Steps for creating database connectivity applications

• Start Python
• Import the packages required for database programming
• Open a connection to the database
• Create a cursor instance
• Execute a query or sql statement
• Extract data from result set
• Clean up the environment
Methods
Of cursor
object

Property
Of cursor
[Link] property of cursor object that returns the number of rows retrieved so far.
object
Using fetchall()

Id name
1 A
2 B
3 c

Data=[ (1,”A”), (2,”B”),(3,”c”)]


Data=[Link]()
(1,”A”)
Data=[Link](2)
[(1,”a”),(2,”b)]
Data=[Link](1)
[(1,”a”)]
Using fetchmany()
Using fetchone()
Using string method format()
%s replaced by value in tuple

You might also like